update: latest changes to multi-tenant branch
This commit is contained in:
@@ -20,15 +20,16 @@ class EmployeeTrainingController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (Auth::user()->can('manage-employee-trainings')) {
|
||||
$user = Auth::user();
|
||||
if ($user->type === 'company' || $user->can('manage-employee-trainings') || $user->can('view-employee-trainings') || $user->can('manage-training') || $user->can('view-training') || $user->can('manage-seminar')) {
|
||||
$query = EmployeeTraining::with(['employee.employee', 'trainingProgram.trainingType'])
|
||||
->where(function ($q) {
|
||||
if (Auth::user()->can('manage-any-employee-trainings')) {
|
||||
->where(function ($q) use ($user) {
|
||||
if ($user->type === 'company' || $user->can('manage-any-employee-trainings') || $user->can('manage-employee-trainings') || $user->can('manage-training')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-own-employee-trainings')) {
|
||||
$q->where('created_by', Auth::id())->orWhere('employee_id', Auth::id());
|
||||
} elseif ($user->can('manage-own-employee-trainings')) {
|
||||
$q->where('created_by', $user->id)->orWhere('employee_id', $user->id);
|
||||
} else {
|
||||
$q->whereRaw('1 = 0');
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user