mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.5 KiB
PHTML
65 lines
1.5 KiB
PHTML
2 years ago
|
<?php
|
||
|
|
||
|
namespace App\Policies;
|
||
|
|
||
|
use App\Models\Invoice;
|
||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||
|
|
||
|
class InvoicePolicy
|
||
|
{
|
||
|
use HandlesAuthorization;
|
||
|
|
||
|
public function viewAny(\App\Models\User $user)
|
||
|
{
|
||
|
return $user->can('ORDER_VIEW');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine whether the user can view the category.
|
||
|
*
|
||
|
* @param \App\Models\User $user
|
||
|
* @param \App\Models\Invoice $category
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function view(\App\Models\User $user, Invoice $invoice)
|
||
|
{
|
||
|
return ($user->id===$invoice->customer_id) or $user->can('ORDER_VIEW');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine whether the user can view the category.
|
||
|
*
|
||
|
* @param \App\Models\User $user
|
||
|
* @param \App\Models\Invoice $category
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function create(\App\Models\User $user)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine whether the user can view the category.
|
||
|
*
|
||
|
* @param \App\Models\User $user
|
||
|
* @param \App\Models\Invoice $category
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function update(\App\Models\User $user, Invoice $invoice)
|
||
|
{
|
||
|
return ($user->id===$invoice->customer_id) or $user->can('ORDER_UPDATE');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine whether the user can view the category.
|
||
|
*
|
||
|
* @param \App\Models\User $user
|
||
|
* @param \App\Models\Invoice $category
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function delete(\App\Models\User $user, Invoice $invoice)
|
||
|
{
|
||
|
return $user->can('ORDER_DELETE');
|
||
|
}
|
||
|
}
|