1. Go to this page and download the library: Download soumen-dey/laravel-role 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/ */
php
$user->getRoleNames(); // returns an array of associated role names
php
$users = User::role('editor')->get(); // Returns only users with role 'editor'
php
use Soumen\Role\Models\Role;
$admin = Role::find('admin');
$roles = Role::whereIn('id', [1, 2])->get();
$users = User::role(1)->get(); // integer as the parameter
$users = User::role($admin)->get(); // Role instance as the parameter
$users = User::role($roles)->get(); // Collection of Role instances as the parameter
$users = User::role('admin')->get(); // string as the parameter
php
use Illuminate\Support\Facades\Blade;
public function boot()
{
// ..
Blade::if('role', function ($rolename) {
return auth()->check() && auth()->user()->is($rolename);
});
}
php
use Illuminate\Support\Facades\Blade;
public function boot()
{
// ..
Blade::if('admin', function () {
return auth()->check() && auth()->user()->is('admin');
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.