30 lines
562 B
PHP

<?php
namespace App\Policies\Admin;
use App\Models\Mount;
use App\Models\User;
class MountPolicy
{
use DefaultPolicies;
protected string $modelName = 'mount';
public function before(User $user, string $ability, string|Mount $mount): ?bool
{
// For "viewAny" the $mount param is the class name
if (is_string($mount)) {
return null;
}
foreach ($mount->nodes as $node) {
if (!$user->canTarget($node)) {
return false;
}
}
return null;
}
}