Open rjcrystal opened 8 years ago
I tried installing the package but could not get it to work since it returns with an error.
+1
+1
Any ETA of the support for laravel 5.2?
+1
+1
+1
+1
+1
+1
+
What's the error?
I get the error FatalErrorException in User.php line 10: Class 'App\Model' not found
All I have done is install laravel and add bican/roles package. no other major changes to namespaces or models. Any ideas why I would be getting this error? user.php starts like this... `<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable; use Bican\Roles\Traits\HasRoleAndPermission; use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract { use Authenticatable, CanResetPassword, HasRoleAndPermission;`
Add a use Illuminate\Database\Eloquent\Model to your 'use' list
thanks SteveFound...so simple but totally missed it. added some more use statements to fix subsequent errors only to find that I get the following error looking like this now but still getting an error `<?php
namespace App;
use App\Task; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Auth\User as Authenticatable; use Bican\Roles\Traits\HasRoleAndPermission; use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract { use Authenticatable, CanResetPassword, HasRoleAndPermission;`
Error I'm getting now is: FatalErrorException in User.php line 15: App\User cannot use Illuminate\Foundation\Auth\User - it is not a trait
managed to register error free using the following...now to test the roles/permissions with 5.2. Thanks for your help SteveFound.
<?php
namespace App;
use App\Task; use Illuminate\Database\Eloquent\Model; use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Passwords\CanResetPassword; use Bican\Roles\Traits\HasRoleAndPermission; use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract { use Authenticatable, CanResetPassword, HasRoleAndPermission;
Looks like it is working fine in 5.2, so far so good.
Excellent. On 2016-02-09 6:09 PM, "Jobielou" notifications@github.com wrote:
Looks like it is working fine in 5.2, so far so good.
— Reply to this email directly or view it on GitHub https://github.com/romanbican/roles/issues/144#issuecomment-182169073.
if someone used the artisan make:auth command, you can use this package by writing your User class as:
use Illuminate\Foundation\Auth\User as Authenticatable;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
class User extends Authenticatable implements HasRoleAndPermissionContract
{
use HasRoleAndPermission;
...
@akrz
When using your solution:
$user->is($role)
returns false even when the role is attached correctly
Solution from @jobielou works for me
I did use make:auth
I can't get this working, here's my User.php:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Authenticatable implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract {
use Authenticatable, CanResetPassword, HasRoleAndPermission;
protected $fillable = [
"name", "email", "password",
];
protected $hidden = [
"password", "remember_token",
];
public function presentations () {
return $this->hasMany( "App/Presentation" );
}
}
Depending on how I alter the file, I get a range of errors:
vagrant@precise64:/vagrant$ php artisan db:seed --class=PermissionsSeeder
[BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::attachRole()
vagrant@precise64:/vagrant$ php artisan db:seed --class=PermissionsSeeder
PHP Fatal error: App\User cannot use Illuminate\Foundation\Auth\User - it is not a trait in /vagrant/app/User.php on line 15
[Symfony\Component\Debug\Exception\FatalErrorException]
App\User cannot use Illuminate\Foundation\Auth\User - it is not a trait
Any ideas?
UPDATE
I'm now using just this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissionContract {
use Authenticatable, CanResetPassword, HasRoleAndPermission;
protected $fillable = [
"name", "email", "password",
];
protected $hidden = [
"password", "remember_token",
];
public function presentations () {
return $this->hasMany( "App/Presentation" );
}
}
Getting the error:
[BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::attachRole()
Herp, I manage to miss the fact that my users array wasn't returning anything because my table got accidentally emptied by another seed.. it seems to be working now.
By updating the function "can" to "canDo", fix the issue of Trait method collision
Thanks @jobielou
does this package support laravel 5.2? laravel 5.2 has new multi-auth and multi-model auth