entrust
entrust copied to clipboard
routeNeedsPermission() and routeNeedsRole() not functional Laravel 5.2
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()
.
+1
Has anyone look into this issue?
@rahmatawaludin I think the issue is mainly cause because of the use of Route filters because those have been deprecated in preference of middleware.
+1
Any news ? I need this because the middleware has no way to redirect user...
I switched to bouncer as future support for this package appears to be questionable.
+1
+1
@bkuhl is bouncer a good alternative to this package? I'm looking for something fully working with 5.2
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.
+1
:+1:
any one solved this issue ?
More opinions about Bouncer?
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!
@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
+1
+1
+1
+1
+1 Any News?
Im worried support for this project has stopped. I may move to bouncer since the project owners last commit to this repo was April.
+1
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
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.
+1
+1 Entrust::routeNeedsRole('admin/advanced*', 'owner'); --> not working
showing error: Attribute [filter] does not exist.
using laravel 5.5
help pls @Zizaco
ErrorException (E_DEPRECATED)
Non-static method Zizaco\Entrust\Entrust::routeNeedsRole() should not be called statically
Entrust::routeNeedsRole('admin/advanced*', 'owner');
using laravel 5.7