over naar uuids, policies, predefined mutations aan kunnen passen
This commit is contained in:
@@ -37,7 +37,15 @@ class LedgerPolicy
|
||||
*/
|
||||
public function update(User $user, Ledger $ledger): bool
|
||||
{
|
||||
return false;
|
||||
return $user->can('update', $ledger->dynamic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can close the model.
|
||||
*/
|
||||
public function close(User $user, Ledger $ledger): bool
|
||||
{
|
||||
return $user->can('update', $ledger->dynamic);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,18 +2,39 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Ledger;
|
||||
use App\Models\Mutation;
|
||||
use App\Models\User;
|
||||
|
||||
class MutationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view the mutation.
|
||||
* Determine whether the user can create mutations.
|
||||
*/
|
||||
public function view(User $user, Mutation $mutation): bool
|
||||
public function create(User $user, Ledger $ledger): bool
|
||||
{
|
||||
$dynamic = $mutation->ledger->dynamic;
|
||||
$dynamic = $ledger->dynamic;
|
||||
|
||||
return $dynamic->participants()->where('user_id', $user->id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the mutation.
|
||||
*/
|
||||
public function update(User $user, Mutation $mutation): bool
|
||||
{
|
||||
$dynamic = $mutation->ledger->dynamic;
|
||||
|
||||
return $dynamic->participants()->where('user_id', $user->id)->where('role', 'owner')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can void the mutation.
|
||||
*/
|
||||
public function void(User $user, Mutation $mutation): bool
|
||||
{
|
||||
$dynamic = $mutation->ledger->dynamic;
|
||||
|
||||
return $dynamic->participants()->where('user_id', $user->id)->where('role', 'owner')->exists();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user