* #118 - wip * #118 - keys * #118 - fix * #118 - fix menu * #118 - fix to policies and added translations * #118 - wip * #118 - tests * #118 - fix * #118 - fix * #118 - fix * Update resources/lang/pl.json Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #118 - cr fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
26
app/Domain/Policies/KeyPolicy.php
Normal file
26
app/Domain/Policies/KeyPolicy.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Policies;
|
||||
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Eloquent\Models\Key;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class KeyPolicy
|
||||
{
|
||||
public function manage(User $user): bool
|
||||
{
|
||||
return $user->role === Role::AdministrativeApprover;
|
||||
}
|
||||
|
||||
public function give(User $user, Key $key): bool
|
||||
{
|
||||
if ($key->user()->is($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->role === Role::AdministrativeApprover;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user