Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

routeNeedsPermission() and routeNeedsRole() not functional Laravel 5.2 #543

Open bkuhl opened 8 years ago

bkuhl commented 8 years ago

Using "zizaco/entrust": "5.2.x-dev" with Laravel 5.2 I'm running into an issue using the route filters. It looks like they aren't yet designed for Laravel 5.2. The error I get when clear-compiled is run is:

  [BadMethodCallException]       
  Method filter does not exist.

Doing some digging it appears to be a result of the use of Entrust::routeNeedsPermission() and Entrust::routeNeedsRole() when it hits filter().

yahyazini commented 8 years ago

+1

rawaludin commented 8 years ago

Has anyone look into this issue?

yahyazini commented 8 years ago

@rahmatawaludin I think the issue is mainly cause because of the use of Route filters because those have been deprecated in preference of middleware.

vaurelios commented 8 years ago

+1

vaurelios commented 8 years ago

Any news ? I need this because the middleware has no way to redirect user...

bkuhl commented 8 years ago

I switched to bouncer as future support for this package appears to be questionable.

sugengsuprayogi commented 8 years ago

+1

essaaam commented 8 years ago

+1

diegoalmesp commented 8 years ago

@bkuhl is bouncer a good alternative to this package? I'm looking for something fully working with 5.2

bkuhl commented 8 years ago

Yes, it's build with a L5-friendly approach, so I think we can expect consistent Laravel 5 support with Bouncer. The author of Bouncer also submitted a PR to Laravel that included some great middleware. I'm using it and it's working well. It didn't take long for me to switch.

tennessine commented 8 years ago

+1

larsbo commented 8 years ago

:+1:

marwankhanfar commented 8 years ago

any one solved this issue ?

quiquegarcia commented 8 years ago

More opinions about Bouncer?

dpovshed commented 8 years ago

My 2 cents: I also spotted that Short syntax route filter failed to proceed with L5.2.

However, by using full format like:

    Route::get('reports', [
        'uses' => 'ReportController@reportsList',
        'middleware' => ['role:manager'],
    ]);

I was able to get things to work. Since that, everything works just fine, including GUI package I am using - https://github.com/acoustep/entrust-gui .

Hope this helps!

marwankhanfar commented 8 years ago

@quiquegarcia its probably too late for me to use Bouncer as I've already setup views and screens. @dpovshed that method worked for me too , I like the routeNeedsRole cause it has redirect url option and its more generic .

Thanks

segadora commented 8 years ago

+1

nerijuso commented 8 years ago

+1

WisdomSky commented 8 years ago

+1

xitude commented 7 years ago

+1

rygos commented 7 years ago

+1 Any News?

xitude commented 7 years ago

Im worried support for this project has stopped. I may move to bouncer since the project owners last commit to this repo was April.

racibaz commented 7 years ago

+1

rencong commented 7 years ago

route filters are not going away entirely after Laravel 5.0 However, middleware is now the preferred way to achieve the same functionality. See http://laravel.com/docs/master/middleware for info about how to use it. Middleware can be implemented to behave like either "before" or "after" filters. And it can be applied to all routes (called "global middleware"), or assigned to specific routes (by adding "'middleware' => 'auth'" for example to your route definitions in your routes.php file.

ref: https://stackoverflow.com/questions/34973173/method-filter-does-not-exist-error-in-laravel

devpake commented 7 years ago

The Short Syntax section of the README needs to be removed or indicated as deprecated if there is no intention of either fixing the filter issue or if middleware is truly going to be the path forward. @Zizaco hopefully you can shed some light on the forward path.

simtrax commented 7 years ago

+1

itsmekps commented 6 years ago

+1 Entrust::routeNeedsRole('admin/advanced*', 'owner'); --> not working

showing error: Attribute [filter] does not exist.

using laravel 5.5

help pls @Zizaco

kostyan-org commented 5 years ago
ErrorException (E_DEPRECATED)
Non-static method Zizaco\Entrust\Entrust::routeNeedsRole() should not be called statically

Entrust::routeNeedsRole('admin/advanced*', 'owner');

using laravel 5.7