test-policy mit mkro zum Filtern von Datensätzen in Tabelle

This commit is contained in:
2026-02-09 01:49:28 +00:00
parent 16085c67f8
commit 1e273deb47
4 changed files with 132 additions and 1 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Policies;
use App\Models\Contract;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Database\Eloquent\Builder;
class ContractPolicy
{
// ContractPolicy.php
public function applyRowAccessPolicy(User $user, Builder $query): Builder
{
// Users can only see their own posts unless they're admins
return $query->where('responsible_id', $user->id);
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Contract $contract): bool
{
return true;
}
/**
* 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, Contract $contract): bool
{
return true;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Contract $contract): bool
{
return true;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Contract $contract): bool
{
return true;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Contract $contract): bool
{
return true;
}
}