add all controllers logic

This commit is contained in:
root
2026-03-11 17:53:15 -04:00
parent 3e6c577085
commit 2ef71cc92b
421 changed files with 12009 additions and 5211 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Policies;
use App\Models\SupportRequest;
use App\Models\User;
class SupportRequestPolicy
{
public function viewAny(User $user): bool
{
return $user !== null;
}
public function view(User $user, SupportRequest $request): bool
{
return $request->user_id === $user->id || $this->isAdmin($user);
}
public function create(User $user): bool
{
return $user !== null;
}
private function isAdmin(User $user): bool
{
$roles = $user->roles()
->pluck('roles.name')
->map(fn ($name) => strtolower((string) $name))
->toArray();
foreach (['administrator', 'admin', 'principal', 'vice_principal', 'vice-principal'] as $role) {
if (in_array($role, $roles, true)) {
return true;
}
}
return false;
}
}