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 @@
-
- {{ __('Dashboard') }}
-
+ @can('viewAny', \App\Models\Grade::class)
+
+ {{ __('Классы') }}
+
+ @endcan
+
+ @can('viewAny', \App\Models\Subject::class)
+
+ {{ __('Предметы') }}
+
+ @endcan
+
+ @can('viewAny', \App\Models\Student::class)
+
+ {{ __('Студенты') }}
+
+ @endcan
+
+ @can('viewAny', \App\Models\Teacher::class)
+
+ {{ __('Учителя') }}
+
+ @endcan
+
+ @can('debts', \App\Models\Student::class)
+
+ {{ __('Задолженности') }}
+
+ @endcan
diff --git a/resources/views/subjects/index.blade.php b/resources/views/subjects/index.blade.php
index ac9887c..82a9ec9 100644
--- a/resources/views/subjects/index.blade.php
+++ b/resources/views/subjects/index.blade.php
@@ -34,11 +34,13 @@
{{ $subject->name }}
+ @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('teacherSubjects', $teacher)
+
+
+ |
+ @endcan
@can('update', $teacher)
| |