ldc-crm/app/Policies/CustomerPolicy.php
Alexis Gousseau 303834bbca
Crm V4
- Make all tests pass Client (V4),CRMV2,CRMV4
- Simplify client submodule path
- Move App_url to .env.testing
2023-10-06 16:37:29 +02:00

75 lines
1.3 KiB
PHP

<?php
namespace App\Policies;
use App\Models\Customer;
use App\Models\Service;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\Policies\Rules\UserStaticRules as USR;
class CustomerPolicy
{
use HandlesAuthorization;
/**
* View a Customer.
*
* @return boolean
*/
public function view(): bool
{
return USR::everyOne();
}
/**
* View any a Customer.
*
* @return boolean
*/
public function viewAny(): bool
{
return USR::everyOne();
}
/**
* Create a Customer.
*
* @return boolean
*/
public function create(): bool
{
return USR::noOne();
}
/**
* Update a Customer.
*
* @return boolean
*/
public function update(): bool
{
return USR::noOne();
}
/**
* Delete a Customer.
*
* @return boolean
*/
public function delete(): bool
{
return USR::everyOne();
}
/**
* Check if the customer belongs to the service.
*
* @param \App\Models\Service $service
* @param \App\Models\Customer $customer
* @return boolean
*/
public function customerBelongsToService(Service $service, Customer $customer)
{
return !\is_null($customer->login($service->brand));
}
}