1. Go to this page and download the library: Download smart-crowd/laravel-rbac library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use SmartCrowd\Rbac\Traits\AllowedTrait;
use SmartCrowd\Rbac\Contracts\Assignable;
class User extends Model implements Assignable
{
use AllowedTrait;
/**
* Should return array of permissions and roles names,
* assigned to user.
*
* @return array Array of user assignments.
*/
public function getAssignments()
{
// your implementation here
}
...
}
if (Auth::user()->allowed('article.delete', ['article' => $article])) {
// user has access to 'somePermission.name' permission
}