feat: Add policies for Assignment, Attendance, Course, CourseSchedule, Lecturer, Material, Role, Student, and StudyGroup to manage authorization rules.
This commit is contained in:
parent
3dddb807f5
commit
9f4224b108
69
app/Policies/AssignmentPolicy.php
Normal file
69
app/Policies/AssignmentPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Assignment;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class AssignmentPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Assignment');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('View:Assignment');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Assignment');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('Update:Assignment');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('Delete:Assignment');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('Restore:Assignment');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Assignment');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Assignment');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Assignment');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Assignment $assignment): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Assignment');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Assignment');
|
||||
}
|
||||
}
|
||||
69
app/Policies/AttendancePolicy.php
Normal file
69
app/Policies/AttendancePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Attendance;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class AttendancePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Attendance');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('View:Attendance');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Attendance');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('Update:Attendance');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('Delete:Attendance');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('Restore:Attendance');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Attendance');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Attendance');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Attendance');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Attendance $attendance): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Attendance');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Attendance');
|
||||
}
|
||||
}
|
||||
69
app/Policies/CoursePolicy.php
Normal file
69
app/Policies/CoursePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Course;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class CoursePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Course');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('View:Course');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Course');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('Update:Course');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('Delete:Course');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('Restore:Course');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Course');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Course');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Course');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Course $course): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Course');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Course');
|
||||
}
|
||||
}
|
||||
69
app/Policies/CourseSchedulePolicy.php
Normal file
69
app/Policies/CourseSchedulePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\CourseSchedule;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class CourseSchedulePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:CourseSchedule');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('View:CourseSchedule');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:CourseSchedule');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('Update:CourseSchedule');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('Delete:CourseSchedule');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('Restore:CourseSchedule');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:CourseSchedule');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:CourseSchedule');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:CourseSchedule');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, CourseSchedule $courseSchedule): bool
|
||||
{
|
||||
return $authUser->can('Replicate:CourseSchedule');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:CourseSchedule');
|
||||
}
|
||||
}
|
||||
69
app/Policies/LecturerPolicy.php
Normal file
69
app/Policies/LecturerPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Lecturer;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class LecturerPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Lecturer');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('View:Lecturer');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Lecturer');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('Update:Lecturer');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('Delete:Lecturer');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('Restore:Lecturer');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Lecturer');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Lecturer');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Lecturer');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Lecturer $lecturer): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Lecturer');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Lecturer');
|
||||
}
|
||||
}
|
||||
69
app/Policies/MaterialPolicy.php
Normal file
69
app/Policies/MaterialPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Material;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class MaterialPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Material');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('View:Material');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Material');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('Update:Material');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('Delete:Material');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('Restore:Material');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Material');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Material');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Material');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Material $material): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Material');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Material');
|
||||
}
|
||||
}
|
||||
69
app/Policies/RolePolicy.php
Normal file
69
app/Policies/RolePolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RolePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Role');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('View:Role');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Role');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Update:Role');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Delete:Role');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Restore:Role');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Role');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Role');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Role');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Role $role): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Role');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Role');
|
||||
}
|
||||
}
|
||||
69
app/Policies/StudentPolicy.php
Normal file
69
app/Policies/StudentPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Student;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class StudentPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:Student');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('View:Student');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:Student');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('Update:Student');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('Delete:Student');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('Restore:Student');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:Student');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:Student');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:Student');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, Student $student): bool
|
||||
{
|
||||
return $authUser->can('Replicate:Student');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:Student');
|
||||
}
|
||||
}
|
||||
69
app/Policies/StudyGroupPolicy.php
Normal file
69
app/Policies/StudyGroupPolicy.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\StudyGroup;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class StudyGroupPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:StudyGroup');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('View:StudyGroup');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:StudyGroup');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('Update:StudyGroup');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('Delete:StudyGroup');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('Restore:StudyGroup');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:StudyGroup');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:StudyGroup');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:StudyGroup');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, StudyGroup $studyGroup): bool
|
||||
{
|
||||
return $authUser->can('Replicate:StudyGroup');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:StudyGroup');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user