설명 없음

ProfessorPolicy.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Policies;
  3. use App\User;
  4. use App\Professor;
  5. use Illuminate\Auth\Access\HandlesAuthorization;
  6. class ProfessorPolicy
  7. {
  8. use HandlesAuthorization;
  9. /**
  10. * Determine whether the user can view any professors.
  11. *
  12. * @param \App\User $user
  13. * @return mixed
  14. */
  15. public function viewAny(User $user)
  16. {
  17. return true;
  18. }
  19. /**
  20. * Determine whether the user can update the professor.
  21. *
  22. * @param \App\User $user
  23. * @param \App\Professor $professor
  24. * @return mixed
  25. */
  26. public function update(User $user, Professor $professor)
  27. {
  28. return $user->departments->where('id', '=', $professor->dept_id)->isNotEmpty()
  29. || $user->faculties->where('id', '=', $professor->faculty->id)->isNotEmpty();
  30. }
  31. /**
  32. * Determine whether the user can delete the professor.
  33. *
  34. * @param \App\User $user
  35. * @param \App\Professor $professor
  36. * @return mixed
  37. */
  38. public function delete(User $user, Professor $professor)
  39. {
  40. return $user->departments->where('id', '=', $professor->dept_id)->isNotEmpty()
  41. || $user->faculties->where('id', '=', $professor->faculty->id)->isNotEmpty();
  42. }
  43. }