user()->hasRole('employee')) { $user = \Auth::user(); $query->where('id', $user->employee_id); } })->paginate(20); } public function getEmployeeById($employeeId) { return Employee::findOrFail($employeeId); } public function getUserByEmpId($employeeId) { $employee = Employee::findOrFail($employeeId); return $employee->user ?? null; } public function getEmployeeByEmail($email) { return Employee::where('email', $email)->first(); } public function delete($employeeId) { Employee::destroy($employeeId); } public function create($employeeDetails) { return Employee::create($employeeDetails); } public function update($employeeId, array $newDetails) { return Employee::whereId($employeeId)->update($newDetails); } public function pluck() { return Employee::pluck(DB::raw('CONCAT(first_name, " ", COALESCE(middle_name, " "), " ", last_name) AS full_name'), 'id'); } }