ldc-crm/app/Policies/CustomerPolicy.php

76 lines
1.3 KiB
PHP
Raw Normal View History

2023-06-20 11:55:52 +02:00
<?php
namespace App\Policies;
use App\Models\Customer;
use App\Models\Service;
use Illuminate\Auth\Access\HandlesAuthorization;
2023-06-20 17:37:15 +02:00
use App\Policies\Rules\UserStaticRules as USR;
2023-06-20 11:55:52 +02:00
class CustomerPolicy
{
use HandlesAuthorization;
2023-06-20 17:37:15 +02:00
/**
* 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();
}
2023-06-20 11:55:52 +02:00
/**
* Check if the customer belongs to the service.
2023-06-20 11:55:52 +02:00
*
2023-06-23 17:18:59 +02:00
* @param \App\Models\Service $service
* @param \App\Models\Customer $customer
2023-06-20 11:55:52 +02:00
* @return boolean
*/
public function customerBelongsToService(Service $service, Customer $customer)
{
return !\is_null($customer->login($service->brand));
}
}