upgrade to filament v4
This commit is contained in:
@@ -1,108 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
use App\Models\Client;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class ClientPolicy
|
||||
{
|
||||
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_client');
|
||||
return $authUser->can('ViewAny:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Client $client): bool
|
||||
public function view(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('view_client');
|
||||
return $authUser->can('View:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('create_client');
|
||||
return $authUser->can('Create:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Client $client): bool
|
||||
public function update(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('update_client');
|
||||
return $authUser->can('Update:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Client $client): bool
|
||||
public function delete(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('delete_client');
|
||||
return $authUser->can('Delete:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk delete.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
public function restore(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('delete_any_client');
|
||||
return $authUser->can('Restore:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete.
|
||||
*/
|
||||
public function forceDelete(User $user, Client $client): bool
|
||||
public function forceDelete(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('force_delete_client');
|
||||
return $authUser->can('ForceDelete:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_client');
|
||||
return $authUser->can('ForceDeleteAny:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore.
|
||||
*/
|
||||
public function restore(User $user, Client $client): bool
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('restore_client');
|
||||
return $authUser->can('RestoreAny:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can bulk restore.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
public function replicate(AuthUser $authUser, Client $client): bool
|
||||
{
|
||||
return $user->can('restore_any_client');
|
||||
return $authUser->can('Replicate:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate.
|
||||
*/
|
||||
public function replicate(User $user, Client $client): bool
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $user->can('replicate_client');
|
||||
return $authUser->can('Reorder:Client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->can('reorder_client');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user