Change ScopeServiceUserAuthorised to ScopeAccountUserAuthorised. Scope payments to AccountUserAuthorised, and added PaymentPolicy
This commit is contained in:
83
app/Models/Policies/PaymentPolicy.php
Normal file
83
app/Models/Policies/PaymentPolicy.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
use App\Models\{Payment,User};
|
||||
|
||||
class PaymentPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the payment.
|
||||
*
|
||||
* @param User $uo
|
||||
* @param Payment $o
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $uo,Payment $o): bool
|
||||
{
|
||||
return $uo->accounts_all->pluck('id')->contains($o->account_id) || $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create services.
|
||||
*
|
||||
* @param User $uo
|
||||
* @return bool
|
||||
*/
|
||||
public function create(User $uo): bool
|
||||
{
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param User $uo
|
||||
* @param Payment $o
|
||||
* @return bool
|
||||
*/
|
||||
public function update(User $uo,Payment $o): bool
|
||||
{
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param User $uo
|
||||
* @param Payment $o
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(User $uo,Payment $o): bool
|
||||
{
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param User $uo
|
||||
* @param Payment $o
|
||||
* @return bool
|
||||
*/
|
||||
public function restore(User $uo,Payment $o): bool
|
||||
{
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param User $uo
|
||||
* @param Payment $o
|
||||
* @return bool
|
||||
*/
|
||||
public function forceDelete(User $uo,Payment $o): bool
|
||||
{
|
||||
return $uo->isWholesaler();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user