1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
-
- namespace App\Policies;
-
- use App\User;
- use App\Professor;
- use Illuminate\Auth\Access\HandlesAuthorization;
-
- class ProfessorPolicy
- {
- use HandlesAuthorization;
-
- /**
- * Determine whether the user can view any professors.
- *
- * @param \App\User $user
- * @return mixed
- */
- public function viewAny(User $user)
- {
- return true;
- }
-
- /**
- * Determine whether the user can update the professor.
- *
- * @param \App\User $user
- * @param \App\Professor $professor
- * @return mixed
- */
- public function update(User $user, Professor $professor)
- {
- return $user->departments->where('id', '=', $professor->dept_id)->isNotEmpty()
- || $user->faculties->where('id', '=', $professor->faculty->id)->isNotEmpty();
- }
-
- /**
- * Determine whether the user can delete the professor.
- *
- * @param \App\User $user
- * @param \App\Professor $professor
- * @return mixed
- */
- public function delete(User $user, Professor $professor)
- {
- return $user->departments->where('id', '=', $professor->dept_id)->isNotEmpty()
- || $user->faculties->where('id', '=', $professor->faculty->id)->isNotEmpty();
- }
-
- }
|