2019-04-03 03:17:21 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-04-03 03:17:21 +02:00
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
class ProductPolicy extends EntityPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new policy instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Checks if the user has create permissions.
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-04-03 03:17:21 +02:00
|
|
|
* @param User $user
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function create(User $user) : bool
|
|
|
|
{
|
2019-11-12 12:36:24 +01:00
|
|
|
return $user->isAdmin() || $user->hasPermission('create_product') || $user->hasPermission('create_all');
|
2019-04-03 03:17:21 +02:00
|
|
|
}
|
|
|
|
}
|