entrust icon indicating copy to clipboard operation
entrust copied to clipboard

routeNeedsPermission() and routeNeedsRole() not functional Laravel 5.2

Open bkuhl opened this issue 8 years ago • 28 comments

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().

bkuhl avatar Mar 12 '16 12:03 bkuhl

+1

yahyazini avatar Mar 17 '16 04:03 yahyazini

Has anyone look into this issue?

rawaludin avatar Mar 17 '16 13:03 rawaludin

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

yahyazini avatar Mar 17 '16 14:03 yahyazini

+1

vaurelios avatar Mar 19 '16 23:03 vaurelios

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

vaurelios avatar Apr 04 '16 14:04 vaurelios

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

bkuhl avatar Apr 04 '16 14:04 bkuhl

+1

sugengsuprayogi avatar Apr 08 '16 08:04 sugengsuprayogi

+1

essaaam avatar Apr 22 '16 15:04 essaaam

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

diegoalmesp avatar Apr 27 '16 21:04 diegoalmesp

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.

bkuhl avatar Apr 27 '16 22:04 bkuhl

+1

tennessine avatar Apr 28 '16 14:04 tennessine

:+1:

larsbo avatar May 22 '16 19:05 larsbo

any one solved this issue ?

marwankhanfar avatar Jul 16 '16 13:07 marwankhanfar

More opinions about Bouncer?

quiquegarcia avatar Jul 17 '16 01:07 quiquegarcia

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!

dpovshed avatar Jul 17 '16 14:07 dpovshed

@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

marwankhanfar avatar Jul 17 '16 15:07 marwankhanfar

+1

segadora avatar Aug 12 '16 10:08 segadora

+1

nerijuso avatar Aug 28 '16 16:08 nerijuso

+1

WisdomSky avatar Sep 09 '16 06:09 WisdomSky

+1

xitude avatar Nov 28 '16 17:11 xitude

+1 Any News?

rygos avatar Dec 02 '16 10:12 rygos

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

xitude avatar Dec 02 '16 10:12 xitude

+1

racibaz avatar Feb 18 '17 19:02 racibaz

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

rencong avatar Jun 21 '17 03:06 rencong

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.

devpake avatar Jun 29 '17 20:06 devpake

+1

simtrax avatar Aug 01 '17 07:08 simtrax

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

showing error: Attribute [filter] does not exist.

using laravel 5.5

help pls @Zizaco

itsmekps avatar Aug 03 '18 13:08 itsmekps

ErrorException (E_DEPRECATED)
Non-static method Zizaco\Entrust\Entrust::routeNeedsRole() should not be called statically

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

using laravel 5.7

kostyan-org avatar Dec 09 '18 22:12 kostyan-org