update: latest changes to multi-tenant branch

This commit is contained in:
2026-08-12 18:44:24 +08:00
parent 80c0a2ea42
commit 3e8abf59f9
486 changed files with 28968 additions and 15306 deletions

View File

@@ -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());
}
});