romanbican / roles

Powerful package for handling roles and permissions in Laravel 5
MIT License
1.16k stars 296 forks source link

laravel 5.3 Declaration of Illuminate\Database\Eloquent\Model::is() must be compatible with Bican\Roles\Contracts\HasRoleAndPermission::is($role, $all = false) #190

Closed Pa6 closed 8 years ago

Pa6 commented 8 years ago

while running romanbincan seed

here is my user model: use Illuminate\Auth\Authenticatable; use Bican\Roles\Traits\HasRoleAndPermission;

use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissions; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Notifications\Notifiable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract, HasRoleAndPermissions { use Authenticatable, CanResetPassword, HasRoleAndPermission, Notifiable;

nikolaynesov commented 8 years ago

Did that work before on Laravel 5.2 ? Did you try this: #189 ?

Pa6 commented 8 years ago

Yes he same code on laravel 5.2 works, but on this new version nop

nikolaynesov commented 8 years ago

@Pa6 Did you try this: #189 ?

Pa6 commented 8 years ago

yes I tried also but no change @nikolaynesov

nikolaynesov commented 8 years ago

@Pa6 sorry I was not able to reproduce your error with my recent pull request #189 but maybe if someone else will report or confirm the issue we can come back to it again. Thank you for your effort.

blakeage commented 8 years ago

I had the same error, and #189 seems to have fixed it for me.

nikolaynesov commented 8 years ago

@Pa6 Are you still experiencing this error today? @blakeage it fixed the issue for me too. @emiliomedina21 should have fixed it in his recent commits and they are included in #189 Anybody else experiencing the same issue?

emiliomedina21 commented 8 years ago

@Pa6 Please review #189 (method is() has conflicts with Model::is() ). It was fixed.

Pa6 commented 8 years ago

@nikolaynesov it is fixed now. Thanks

LucaColombi commented 7 years ago

Hello,

I have the same issue on 5.4, seems that Model declare a new is() method that conflicts with code that used this metods on Model subclasses

LucaColombi commented 7 years ago

for compatibility it would be better to name the new metod equals(), since it is more standard for object comparing, moreover is() is often user to verify boolean attributes: is('enabled'), is('admin'), etc.... (that's my case)

Pa6 commented 7 years ago

@LucaColombi check the issue #189, It is fixed for laravel 5.4 as well!

sanslash332 commented 7 years ago

Hello, I have the same issue, with laravel 5.4, and roles was installed using require bican/roles:dev-master --dev This is the displayed exception:

Whoops, looks like something went wrong.

(1/1) FatalErrorException

Declaration of Illuminate\Database\Eloquent\Model::is() must be compatible with Bican\Roles\Contracts\HasRoleAndPermission::is($role, $all = false) 

in User.php (line 14)

Is a clean installation of laravel 5.4 without add anythin more tan bican/roles. This is mi User.php File:

<?php

namespace App;

use Illuminate\Notifications\Notifiable; 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 Notifiable; use HasRoleAndPermission;

What I have to do to fix it?

thanks.

sanslash332 commented 7 years ago

sorry for the doble post (i can't find the edit button) this is the code of the file:

<?php

namespace App;

use Illuminate\Notifications\Notifiable; 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 Notifiable; use HasRoleAndPermission; ...

What i have to fix it? thankx :P