Level 70
@inlogic How about this?
$res = AttendanceNotice::query()
->withoutGlobalScopes()
->join('guardians', function ($join) {
$join->on('guardians.custom_column', '=', 'attendance_notices.reportable_id')
->where('attendance_notices.reportable_type', Guardian::class);
})
->orWhere(function ($query) {
$query->join('employees', function ($join) {
$join->on('employees.custom_column', '=', 'attendance_notices.reportable_id')
->where('attendance_notices.reportable_type', Employee::class);
});
})
->get();
1 like