spatie / laravel-permission Goto Github PK
View Code? Open in Web Editor NEWAssociate users with roles and permissions
Home Page: https://spatie.be/docs/laravel-permission
License: MIT License
Associate users with roles and permissions
Home Page: https://spatie.be/docs/laravel-permission
License: MIT License
If I spatie / laravel-permission and spatie / laravel-authorize install, I can not authorize use.
I get an error message in route.php. The normal Routes will no longer work. What am I doing wrong?
A default value needs to be added in the, which should be used in the service provider.
How get $user->getAllPermisiion();
I love this package!!! We use it all through out our sites. Having said that, there is one functionality that I haven't been able to find but desperately needed... so I added it to my files but would greatly appreciate if any new releases included this in the HasPermissions.php file...
/**
* Determine if the role has (one of) the given permission(s).
*
* @param string|array|Permission|\Illuminate\Support\Collection $roles
*
* @return bool
*/
public function hasPermission($permissions)
{
if (is_string($permissions)) {
return $this->permissions->contains('name', $permissions);
}
if ($permissions instanceof Permission) {
return $this->permissions->contains('id', $permissions->id);
}
if (is_array($permissions)) {
foreach ($permissions as $permission) {
if ($this->hasPermission($permission)) {
return true;
}
}
return false;
}
return (bool) $permissions->intersect($this->permissions)->count();
}
PS. If this functionality exists and I just haven't found it please let me know so that I can use this better.
Cheers,
Jay
How can a super user have access to all permissions automatically without manually granting each one.
Thanks for sharing this... it's awesome. I need to obtain a list of permissions granted to a role. It appears that the hasPermissionTo method is for the user model only. Is there a means that I've overlooked to get a list of permissions granted to a role? At the moment, I'm getting by with:
in_array($permission->name, $role->permissions->pluck('name')->all())
Hi,
I am running Laravel 5.2.25 and i succesfully created roles and assigned permission to those roles.
(role "admin" has permission "create-user").
Calling "hasPermissionTo" and "hasRole" on a user is working fine. Calling $user-can('create-user') is simply doing nothing. No Exception. No return.
any ideas?
I'm wondering if there's a design rationale for the "name" columns to be non-unique? It doesn't really seem like you'd want multiple permissions & roles with the same name.
Hi,
Thanks a lot for this nice package,
As I saw there's @ROLE('...') for view, so is there @Permission('...') for view too ?
Regards
$role->givePermissionTo('edit');
Call to undefined method Illuminate\Database\Query\Builder::forgetCachedPermissions() error
HasPermissions.php file
public function givePermissionTo($permission)
{
$this->permissions()->save($this->getStoredPermission($permission));
$this->forgetCachedPermissions();
return $this;
}
It does not have this function forgetCachedPermissions()
I have this code :
return User::find($id)->hasPermission($permission);
It returns true if $permission exists, and this error when not :
ErrorException in HasRoles.php line 174: Trying to get property of non-object
Please Help me
Hello
nice package. would it be possible to add a "Teams" or "Workspaces" a la spark on top of roles ?
For my saas project i would need a user-teams role definition so that I can have administrators, team administrators and members roles for each team. Permissions would be declared one time only like read, write, updated, delete, etc ... and would be reusable across roles. So one user could have many teams and in each team it would have different roles, connected with different permissions.
I'm asking instead of doing because i'm not sure how to figure it out.
have nice day
Francois
After successfully assigning users to role, I tried calling the givePermissionTo() method to give my roles permission and I get the above error. I added the HasRole trait to my users model as it says in the README. However I'm not quite sure where to put use Spatie\Permission\Models\Role;
and use Spatie\Permission\Models\Permission;
Could this be the cause of the error? Thanks
Hi there,
I upgraded from version 5.1. following http://laravel.com/docs/5.1/upgrade#upgrade-5.1.11
Everything seems to work but $user->can('create post') is false when $user->hasPermissionTo('create post') is true... What I'm missing?
Thanks!
When I have added Spatie\Permission\PermissionServiceProvider::class to my config/app.php file, PHP Artisan no longer works so I am unable to continue with the installation steps.
This is occurring in Laravel 5.2.
First of all, excellent work!
Is there an easy way to add "haspermition" on registerBladeExtensions without messing up with this extension?
This would be useful no?
Cheers
Is it possible to check if a role has a specific permission?
For example, I want to display all roles and all its permissions. What I'm doing now is just:
foreach (Role::all() as $role) {
$permissions = $role->permissions);
// Etc..
}
But I'm looking for something like:
foreach (Role::all() as $role) {
dd($role->can('view-user')); // Example
}
It will be very useful when dealing with many roles and permissions.
I would write it, but my testing skills is not good enough to make a PR.
can i use role in route?
i try to use
Route::group(['middleware' => 'role:admin'], function () { Route::get('/admin', 'adminController@view'); });
but im gettin error
Class hasRole does not exist
Hi, thanks for amazing package.
Do you think permission/roles tables should include one more field for display name?
Hi, how I can get the user list that have the specific roles?
Not sure if this is a bug or if it's just me.
I would like to get all the users which have permission to 'write_post'.
$users = User::where(function ($q) {
$q->hasPermissionTo('write_post');
})->get();
this fails with a BadMethodCallException thrown with message "Call to undefined method Illuminate\Database\Query\Builder::hasPermissionTo()"
I cannot find a way in the document how to allow access any model associated with the current user. Is it possible with this package? Thanks.
Having problem with migration after installation:
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"
Nothing to publish for tag [migrations]
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="config"
Nothing to publish for tag [config]
Laravel 5.2
How to test if user has one or more roles ?
Example:
There is 3 roles: admin, support, staff
User A is assigned for roles admin
If I want to know if user A has roles admin or staff.
Trying to use hasAnyRoles but no luck
Is this bug ?
When hasAnyRole('admin','staff') will return true
When hasAnyRole('staff','admin') will return false
Thanks
I have a seeder which truncates the Users table, but when I run artisan db:seed
, I get this error message:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation:
1701 Cannot truncate a table referenced in a foreign key constraint (`mydatabasename`.`user_has_permissions`, CONSTRAINT `user_has_permissions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `mydatabasename`.`users` (`id`)) (SQL: truncate `users`)
I've managed to get around it by disabling and reenabling foreign_key_checks around the truncate method.
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::table('users')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
Is there better way of addressing this issue?
Hi
I've ran into the case that I need to be able to assign a description to the Permission model.
Normally, one would extend the Permission class and proceed, however this won't work with this package since both Role and Permission classes are quite a lot hard-coded using class imports.
Some suggestions:
auth.model
Great package! Upon initial spectation of the readme, doesnt seem to have a "nice name" attribute for roles and permissions.
Say a role is "editor" but on the Frontend you would like it to say "Site Editor".
This error occurred when executing the command $role->givePermissionTo($permission->name);
PDOException in Connection.php line 390: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role_id' in 'field list'
in Connection.php line 390
at PDO->prepare('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)') in Connection.php line 390
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1')) in Connection.php line 648
at Connection->runQueryCallback('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1'), object(Closure)) in Connection.php line 611
at Connection->run('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1'), object(Closure)) in Connection.php line 391
at Connection->statement('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1')) in Connection.php line 347
at Connection->insert('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1')) in Builder.php line 1805
at Builder->insert(array(array('role_id' => '1', 'permission_id' => '1'))) in BelongsToMany.php line 898
at BelongsToMany->attach('1', array(), true) in BelongsToMany.php line 558
at BelongsToMany->save(object(Permission)) in HasPermissions.php line 18
at Role->givePermissionTo('crear usuarios') in AuxpermisosController.php line 65
at AuxpermisosController->store(object(Request))
at call_user_func_array(array(object(AuxpermisosController), 'store'), array(object(Request))) in Controller.php line 256
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(AuxpermisosController), object(Route), 'store') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(AuxpermisosController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AuxpermisosController', 'store') in Route.php line 203
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 708
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 710
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 675
at Router->dispatchToRoute(object(Request)) in Router.php line 635
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Debugbar.php line 49
at Debugbar->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
QueryException in Connection.php line 655: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role_id' in 'field list' (SQL: insert into user_has_permissions
(permission_id
, role_id
) values (1, 1))
in Connection.php line 655
at Connection->runQueryCallback('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1'), object(Closure)) in Connection.php line 611
at Connection->run('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1'), object(Closure)) in Connection.php line 391
at Connection->statement('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1')) in Connection.php line 347
at Connection->insert('insert into `user_has_permissions` (`permission_id`, `role_id`) values (?, ?)', array('1', '1')) in Builder.php line 1805
at Builder->insert(array(array('role_id' => '1', 'permission_id' => '1'))) in BelongsToMany.php line 898
at BelongsToMany->attach('1', array(), true) in BelongsToMany.php line 558
at BelongsToMany->save(object(Permission)) in HasPermissions.php line 18
at Role->givePermissionTo('crear usuarios') in AuxpermisosController.php line 65
at AuxpermisosController->store(object(Request))
at call_user_func_array(array(object(AuxpermisosController), 'store'), array(object(Request))) in Controller.php line 256
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(AuxpermisosController), object(Route), 'store') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(AuxpermisosController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AuxpermisosController', 'store') in Route.php line 203
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 708
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 710
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 675
at Router->dispatchToRoute(object(Request)) in Router.php line 635
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Debugbar.php line 49
at Debugbar->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
I have been trying to get @can to work for the past hour..
I have a permission setup for the role "President" with the permission "full-access". All have been assigned and my test user has been assigned the role of president.
When I do
@can('full-access')
<p>See This</p>
@endcan
I can't actually see that. Am I doing something wrong in this setup?
Since Laravel 5.2 has already supported Mupltiple Authentication, configurations like User Permissions Table (user_has_permissions
) and User Roles Table (user_has_roles
) should be attached to drives (array? maybe). Creating a branch for Laravel 5.2.* and higher is a great idea, I think.
Moreover, I think we should keep the naming convention of pivot tables of default configurations between these entities:
User - Permission table : permission_user
User - Role table: role_user
Permission - Role table: permission_role
I'm using this packaged and it's very helpful, so thank you! It's the right balance of simple, yet fully functional. You've done great work.
I just have a minor suggestion to put on your README:
It doesn't say anywhere that you can directly access the associated roles and permissions for a user. For example, it would be nice for people to know that you can loop through all of a user's roles by doing something like this:
`foreach ($user->roles as $role)
{
}
`
I found this useful while creating an administration page with a list of all the users and their role(s).
It would be really best if you can provide an example usage of your package
A wiki perhaps?
Ive been able to require it in the package and migrate
dont know if i will create a Model App\Permission , App\Roles
to set the database so far i see it is all in the vendor package
Dont really wanna messed up your code
by adding protected $table = 'roles'; etc.
Or can it be extended , or implements
inside controller or model.
Sorry hope you can really give a detailed set up and usage
๐
Hi, quick and simple question - it doesn't seem that it supports multi auth at the moment, I was wondering whether you are going to add support for it?
I'm facing a issue since this morning i get this error.
FatalErrorException in Model.php line 986: Class 'App\Role' not found
in my controller i added
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\User;
use Spatie\Permission\Models\Role as Role;
use Spatie\Permission\Models\Permission as Permission;
in my view
@can('manage_departments')
test
@endcan
Do you have any suggestions?
It would be useful to have a blade directive that checks if a user has all or any of a given list (array) of roles. The syntax could be like this:
@has(['role_1', 'role_2', 'role_3'])
<some html/php here>
@else
<some other html/php here>
@endhas
What are your thoughts on this?
When editing the migration file to add some more columns in the table and try to migrate it it says: "Class CreatePermissionTables" not found. Do you have any hint for that?
Also, If you made it so that we have slugs that would be awesome! I have found a few situations where I've been using ajax requests with these and slugs are mandatory for me. Not a massive pain to convert these to slugs and then back out of slug every time but, it's an extra step that could be quite automated.
Thanks again for the awesome package!
Hi,
The auth configuration file in Laravel 5.2 changed :
https://github.com/laravel/laravel/blob/develop/config/auth.php
So \Config::get( 'auth.table' )
in the migration file will no longer get the auth related table.
Not sure how to get that table name with the new Laravel version...
Thanks,
Xavier
Hi,
I want to use @hasanyrole(Role::all()) in my Blade Template, but then i see error:
FatalErrorException in 9ab5bebbf6ae5ee24e88699faa66ec40 line 8: Class 'Role' not found
My template:
@section('htmlBody')
...
@hasanyrole(Role::all())
I have one or more of these roles!
@else
I have none of these roles...
@endhasanyrole
...
@endsection
My Controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Spatie\Permission\Models\Role;
class clientArea extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(){
$user = Auth::user();
var_dump($user->hasAnyRole(Role::all()));
return view('page.clientArea.index');
}
}
In config\app.php:
'providers' => [
...
Spatie\Permission\PermissionServiceProvider::class,
...
Whats wrong?
Greetings
// sorry for my english
Please add a function to check if a role name or permission name exist in the table before creating a role and permission. Otherwise same entry can exist in role table and permission table.
I guess this would be really usefull.
Lets say we have 3 rolls: admin, editiors, and readers.
And we have the permission: create posts. This one is given to admins and editors.
Now i would be able to show the create post button only for admins and editors with something like
@hasPermission('create posts')
Think that would be really helpful for a future release.
Regards
Michael
I think it's likely pretty common that a lot of us already have tables (from some other 3rd party acl) to do most of what this migrates. In interest of keeping db changes to a minimum, it'd be ideal for something like this
'tables' => [
'permissions' => env('PERMISSIONS_TABLE','permissions'),
'user_has_permissions' => env('USER_HAS_PERMISSIONS_TABLE','user_has_permissions'),
]
and so on with the rest of the tables.
Short issue, I have every table you're creating already, just named differently
I have the same issue as this :
#13
Please Help me !
[Symfony\Component\Debug\Exception\FatalThrowableError] Fatal error: Class 'CreatePermissionTables' not found
Getting following above error on migrate refresh.
Hi, I'm very begginer with Laravel. I try to use your awesome package.
I found error when running php artisan db:seed
[BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::assignRole()
Here my UserTableSeeder:
'admin']); ``` $password = 1234; // ---------- Administrator $user = User::create([ 'name' => 'Administrator', 'email' => '[email protected]', 'password' => $password, ]); $user->assignRole($adminRole); ``` or same $user->assignRole('admin'); Could you explain to me, how to make usertableseeder? ThanksI want to make models for various roles that I make. So E.g., I'd be making a role called admin, and then for the Admin model, so that it'd be really easy to do things like Admin::all
and so on.
I think that it can be done with Global Scopes.
Test (THIS WORKS)
$role = Role::where('name', "admin")->first();
User::whereHas('roles', function($query) use ($role){
$query->where('roles.id', $role->id);
})->get());
But this does not work.
Admin.php
class Admin extends Model
{
use HasRoles;
protected $role = "admin";
protected $table = "users";
public static function boot()
{
static::addGlobalScope(new AdminScope());
}
}
AdminScope.php
public function apply(Builder $builder, Model $model)
{
$role = Role::where('name', "admin")->first();
return $builder->whereHas('roles', function($query) use ($role){
$query->where('roles.id', $role->id);
});
}
I get
QueryException in Connection.php line 651:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_has_roles.admin_id' in 'where clause' (SQL: select * from `users` where exists (select * from `roles` inner join `user_has_roles` on `roles`.`id` = `user_has_roles`.`role_id` where `user_has_roles`.`admin_id` = `users`.`id` and `roles`.`id` = 2))
Let me know if you need any other code. Thanks!
It would be useful to have methods to check whether a user has any of a list of roles or whether a user has all of a list of roles.
If you agree with this, I can create a PR to add these methods.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.