diff --git a/app/Policies/StudentPolicy.php b/app/Policies/StudentPolicy.php index b30c231..c0f2155 100644 --- a/app/Policies/StudentPolicy.php +++ b/app/Policies/StudentPolicy.php @@ -47,4 +47,9 @@ class StudentPolicy { return $user->userable_type != Admin::class; } + + public function debts(User $user): bool + { + return $user->userable_type == Student::class; + } } diff --git a/app/Policies/SubjectPolicy.php b/app/Policies/SubjectPolicy.php index d62acbb..425db37 100644 --- a/app/Policies/SubjectPolicy.php +++ b/app/Policies/SubjectPolicy.php @@ -3,11 +3,17 @@ namespace App\Policies; use App\Models\Admin; +use App\Models\Student; use App\Models\Subject; +use App\Models\Teacher; use App\Models\User; class SubjectPolicy { + public function viewAny(User $user): bool + { + return $user->userable_type != Teacher::class; + } /** * Determine whether the user can create models. */ @@ -31,4 +37,9 @@ class SubjectPolicy { return $user->userable_type == Admin::class; } + + public function scores(User $user, Subject $subject): bool + { + return $user->userable_type == Student::class; + } } diff --git a/app/Policies/TeacherPolicy.php b/app/Policies/TeacherPolicy.php index 209a5d4..cfe16d9 100644 --- a/app/Policies/TeacherPolicy.php +++ b/app/Policies/TeacherPolicy.php @@ -48,4 +48,9 @@ class TeacherPolicy { return $user->userable_type == Admin::class; } + + public function teacherSubjects(User $user, Teacher $teacher): bool + { + return $user->userable_type == Student::class; + } } diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index 678f1be..18921fb 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -5,49 +5,49 @@
- - - +
- @if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class) - - @endif + @can('viewAny', \App\Models\Grade::class) + + @endcan - + @can('viewAny', \App\Models\Subject::class) + + @endcan - @if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class) - - @endif + @can('viewAny', \App\Models\Student::class) + + @endcan - @if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Teacher::class) - - @endif + @can('viewAny', \App\Models\Teacher::class) + + @endcan - @if(\Illuminate\Support\Facades\Auth::user()->userable_type == \App\Models\Student::class) + @can('debts', \App\Models\Student::class) - @endif + @endcan
@@ -99,9 +99,35 @@ + @can('scores', $subject)
Оценки
+ @endcan @can('update', $subject)
diff --git a/resources/views/teachers/index.blade.php b/resources/views/teachers/index.blade.php index 927aa8f..7490690 100644 --- a/resources/views/teachers/index.blade.php +++ b/resources/views/teachers/index.blade.php @@ -31,14 +31,20 @@
- {{ $teacher->fio }} -
- - -
- Предметы + @can('view', $teacher) + {{ $teacher->fio }} + @else + {{ $teacher->fio }} + @endcan
+ @can('teacherSubjects', $teacher) + +
+ Предметы +
+ + @endcan @can('update', $teacher)