25 lines
482 B
PHP
25 lines
482 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
trait HasPermissionTrait
|
|
{
|
|
use ResponseTrait;
|
|
|
|
public function checkPermission($permission)
|
|
{
|
|
if (Auth::user()->hasPermissionTo($permission, 'web')) {
|
|
return true;
|
|
}
|
|
|
|
return $this->responseError([], 'You have no access on this feature', 403);
|
|
}
|
|
|
|
public function handlePermission($permission)
|
|
{
|
|
return $this->checkPermission($permission);
|
|
}
|
|
}
|