I have a Laravel 5.3 project with the Cartalyst\Sentinel (v2.0.15) package configured. I have this line
$hasPermission = Sentinel::getUser()->hasAccess($routeName);
But I keep getting this error message:
Argument 2 passed to
Cartalyst\Sentinel\Permissions\StandardPermissions::prepare Permissions() must be of the type array, null given
I had a look on Google and the package's github page but couldn't find anything that would help me to solve this problem.
When I look in the source code of the package then I see this piece of code:
/**
* {@inheritDoc}
*/
protected function createPreparedPermissions()
{
$prepared = [];
// $this->secondaryPermissions equals to:
// [
// 0 => NULL,
// ]
if (! empty($this->secondaryPermissions)) {
foreach ($this->secondaryPermissions as $permissions) {
// this is the line where it throws the error as $permissions == NULL
$this->preparePermissions($prepared, $permissions);
}
}
if (! empty($this->permissions)) {
$permissions = [];
$this->preparePermissions($permissions, $this->permissions);
$prepared = array_merge($prepared, $permissions);
}
return $prepared;
}
The secondaryPermissions array isn't empty. What are these 'secondary' permissions? I had a look on Sentinel's documentation page(s) but couldn't find anything about this. The only thing I could find is that a 'user' can have permissions but so does a 'role'. My current database setup is that roles have permissions but none of my users have any specific permissions. So the 'permissions' field in my users table always equals to NULL.
Thanks.