Models refactor + Basic functionnalities
Some checks failed
linter / quality (push) Failing after 3m25s
tests / ci (push) Failing after 12m2s

This commit is contained in:
2025-08-26 12:12:02 +02:00
parent 715d2a884a
commit 55a52086c1
49 changed files with 1074 additions and 269 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Policies;
use App\Models\Resume;
use App\Models\ResumeComponentPlacement;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class ResumeComponentPlacementPolicy
{
private function isCreator(User $user, ResumeComponentPlacement $componentPlacement): Response
{
return $user->id === $componentPlacement->load('resume')->resume->creator_id
? Response::allow()
: Response::deny('You do not own the resume of the component placement.');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ResumeComponentPlacement $componentPlacement): Response
{
return $this->isCreator($user, $componentPlacement);
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return true;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ResumeComponentPlacement $componentPlacement): Response
{
return $this->isCreator($user, $componentPlacement);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ResumeComponentPlacement $componentPlacement): Response
{
return $this->isCreator($user, $componentPlacement);
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, ResumeComponentPlacement $componentPlacement): Response
{
return $this->isCreator($user, $componentPlacement);
}
}