|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace App\Policies; |
| 6 | + |
| 7 | +use App\Models\SponsorDomain; |
| 8 | +use App\Models\User; |
| 9 | +use Illuminate\Auth\Access\HandlesAuthorization; |
| 10 | + |
| 11 | +class SponsorDomainPolicy |
| 12 | +{ |
| 13 | + use HandlesAuthorization; |
| 14 | + |
| 15 | + /** |
| 16 | + * Determine whether the user can view any models. |
| 17 | + */ |
| 18 | + public function viewAny(User $user): bool |
| 19 | + { |
| 20 | + return $user->can('view-sponsors'); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Determine whether the user can view the model. |
| 25 | + */ |
| 26 | + public function view(User $user, SponsorDomain $sponsorDomain): bool |
| 27 | + { |
| 28 | + return $user->can('view-sponsors'); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Determine whether the user can create models. |
| 33 | + */ |
| 34 | + public function create(User $user): bool |
| 35 | + { |
| 36 | + return $user->can('manage-sponsors'); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * Determine whether the user can update the model. |
| 41 | + */ |
| 42 | + public function update(User $user, SponsorDomain $sponsorDomain): bool |
| 43 | + { |
| 44 | + return $user->can('manage-sponsors'); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Determine whether the user can delete the model. |
| 49 | + */ |
| 50 | + public function delete(User $user, SponsorDomain $sponsorDomain): bool |
| 51 | + { |
| 52 | + return $user->can('manage-sponsors'); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Determine whether the user can restore the model. |
| 57 | + */ |
| 58 | + public function restore(User $user, SponsorDomain $sponsorDomain): bool |
| 59 | + { |
| 60 | + return $user->can('manage-sponsors'); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Determine whether the user can permanently delete the model. |
| 65 | + */ |
| 66 | + public function forceDelete(User $user, SponsorDomain $sponsorDomain): bool |
| 67 | + { |
| 68 | + return false; |
| 69 | + } |
| 70 | + |
| 71 | + public function replicate(User $user, SponsorDomain $sponsorDomain): bool |
| 72 | + { |
| 73 | + return false; |
| 74 | + } |
| 75 | +} |
0 commit comments