2024-06-22 23:59:16 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\Admin;
|
|
|
|
use App\Models\Student;
|
|
|
|
use App\Models\User;
|
|
|
|
|
|
|
|
class StudentPolicy
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view any models.
|
|
|
|
*/
|
|
|
|
public function viewAny(User $user): bool
|
|
|
|
{
|
|
|
|
return $user->userable_type != Student::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view the model.
|
|
|
|
*/
|
|
|
|
public function view(User $user, Student $student): bool
|
|
|
|
{
|
2024-06-24 00:51:05 +04:00
|
|
|
return $user->userable_type == Admin::class;
|
2024-06-22 23:59:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can create models.
|
|
|
|
*/
|
|
|
|
public function create(User $user): bool
|
|
|
|
{
|
2024-06-24 00:51:05 +04:00
|
|
|
return $user->userable_type == Admin::class;
|
2024-06-22 23:59:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can update the model.
|
|
|
|
*/
|
|
|
|
public function update(User $user, Student $student): bool
|
|
|
|
{
|
2024-06-24 00:51:05 +04:00
|
|
|
return $user->userable_type == Admin::class;
|
2024-06-22 23:59:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can delete the model.
|
|
|
|
*/
|
|
|
|
public function delete(User $user, Student $student): bool
|
|
|
|
{
|
2024-06-24 00:51:05 +04:00
|
|
|
return $user->userable_type == Admin::class;
|
2024-06-22 23:59:16 +04:00
|
|
|
}
|
2024-06-23 20:26:00 +04:00
|
|
|
|
|
|
|
public function debts(User $user): bool
|
|
|
|
{
|
|
|
|
return $user->userable_type == Student::class;
|
|
|
|
}
|
2024-06-22 23:59:16 +04:00
|
|
|
}
|