<?php
namespace App\Policies; use App\Enums\RoleName; use App\Models\{Keyword,Project,User};
class KeywordPolicy {
 public function viewAny(User $u):bool{return $u->hasRole(RoleName::Customer)||$u->hasPermission('keywords.view');}
 public function view(User $u,Keyword $k):bool{return $k->project->user_id===$u->id||$u->hasPermission('keywords.view');}
 public function create(User $u,Project $p):bool{return $p->user_id===$u->id&&$u->hasRole(RoleName::Customer);}
 public function update(User $u,Keyword $k):bool{return $k->project->user_id===$u->id||$u->hasPermission('keywords.manage');}
 public function archive(User $u,Keyword $k):bool{return $this->update($u,$k);} public function restore(User $u,Keyword $k):bool{return $this->update($u,$k);}
 public function delete(User $u,Keyword $k):bool{return false;} public function deleteAny(User $u):bool{return false;}
}