PHP code example of wovosoft / laravel-permissions
1. Go to this page and download the library: Download wovosoft/laravel-permissions 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/ */
wovosoft / laravel-permissions example snippets
//other imports goes here
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasRoles;
// other codes goes here
}
if(auth()->can('permission')){
echo "Auth user is allowed to perform this operation";
}
if(App\User::find(1)->can('permission')){
echo "Auth user is allowed to perform this operation";
}
$role = Wovosoft\LaravelPermissions\Models\Roles::find(1);
if($role->hasAbility('permission')){
echo "The Role with ID 1 is allowed to perform this operation";
}