PHP code example of klc / permission
1. Go to this page and download the library: Download klc/permission 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/ */
klc / permission example snippets
$user = User::where('id', 1)->first();
dump($user->hasPermission('foo'));
dump($user->hasPermission('bar'));
dump($user->hasPermission('baz'));
dump($user->hasPermission('other'));
true
true
false
true
$user = User::where('id', 1)->first();
dump($user->hasRole('admin'));
dump($user->hasRole('client'));
dump($user->hasRole('foo'));
true
true
false