auth
This commit is contained in:
1 parent
b005c7677e
commit
59eea97d5a
21 files changed
+597
-779
No files matched your search
@@ -1,108 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\Konto;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class KontoPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('view_any_kontos::konto');
|
||||
return $authUser->can('ViewAny:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Konto $konto): bool
|
||||
public function view(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('view_kontos::konto');
|
||||
return $authUser->can('View:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('create_kontos::konto');
|
||||
return $authUser->can('Create:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Konto $konto): bool
|
||||
public function update(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('update_kontos::konto');
|
||||
return $authUser->can('Update:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Konto $konto): bool
|
||||
public function delete(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('delete_kontos::konto');
|
||||
return $authUser->can('Delete:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk delete.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
public function restore(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('delete_any_kontos::konto');
|
||||
return $authUser->can('Restore:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete.
|
||||
*/
|
||||
public function forceDelete(User $user, Konto $konto): bool
|
||||
public function forceDelete(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('force_delete_kontos::konto');
|
||||
return $authUser->can('ForceDelete:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently bulk delete.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('force_delete_any_kontos::konto');
|
||||
return $authUser->can('ForceDeleteAny:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore.
|
||||
*/
|
||||
public function restore(User $user, Konto $konto): bool
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('restore_kontos::konto');
|
||||
return $authUser->can('RestoreAny:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk restore.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
public function replicate(AuthUser $authUser, Konto $konto): bool
|
||||
{
|
||||
return $user->can('restore_any_kontos::konto');
|
||||
return $authUser->can('Replicate:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate.
|
||||
*/
|
||||
public function replicate(User $user, Konto $konto): bool
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('replicate_kontos::konto');
|
||||
return $authUser->can('Reorder:Konto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->can('reorder_kontos::konto');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user