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