Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to Attach ENTRUST Middleware on Laravel 5.1 Route Group #402

Closed
reesejohn69 opened this issue Oct 21, 2015 · 13 comments
Closed

Failed to Attach ENTRUST Middleware on Laravel 5.1 Route Group #402

reesejohn69 opened this issue Oct 21, 2015 · 13 comments

Comments

@reesejohn69
Copy link

I've run the migration and created the models.

I only changed the following two lines on config/entrust.php file.

'role' => App\Role::class,
'permission' => App\Permission::class,

On config/app.php file, I've done the followings.

  • Added the service provider.
Zizaco\Entrust\EntrustServiceProvider::class,
  • Added the alias.
'Entrust'   => Zizaco\Entrust\EntrustFacade::class,

I'm planning to use middleware, so I've also updated the app/Http/Kernel.php file.

protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
    'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
    'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
];

Now I'm getting an exception when I attach 'middleware' => ['role:admin'] to the route group.

// app/Http/routes.php

Route::group(['middleware' => ['role:admin']], function() {
    Route::get('welcome', 'WelcomeController@index');
});

Exception

ReflectionException in Container.php line 737:
Class Zizaco\Entrust\Middleware\EntrustRole does not exist

PLEASE HELP!

@reesejohn69
Copy link
Author

UPDATE
dev-laravel-5 branch is broken or something. This workaround helped! #397 (comment)

Thanks @tuwannu!

@pedzed
Copy link

pedzed commented Oct 28, 2015

I am having this issue as well. The files are simply missing. I am using these classes as a temporary fix instead:
https://raw.githubusercontent.com/tuwannu/entrust/master/src/Entrust/Middleware/EntrustAbility.php
https://raw.githubusercontent.com/tuwannu/entrust/master/src/Entrust/Middleware/EntrustRole.php
https://raw.githubusercontent.com/tuwannu/entrust/master/src/Entrust/Middleware/EntrustPermission.php

@scottpd
Copy link

scottpd commented Nov 5, 2015

Also having this issue.

@vijaythecoder
Copy link

@pedzed
Placing the three missing files , fixed the issue. Thanks

@joaoprado
Copy link

I'm having the same issue, how do I update the files?

@andrewelkins
Copy link
Collaborator

I'll get those in immediately.

@andrewelkins
Copy link
Collaborator

Added the files: be28aa6

@joaoprado
Copy link

Perfect! It works now. Thank you.

@andrewelkins
Copy link
Collaborator

Closing with the files added.

@case90
Copy link

case90 commented Feb 22, 2016

Sorry for my question, Where I should add these files ??

@orkempire
Copy link

@case90, you don't have to. They are already added to the latest version by author.

@basheer-atx
Copy link

All three missing files are available in latest version yet also getting the issue.

when I am running this command as: php artisan entrust:migration

Issue: Method Zizaco\Entrust\MigrationCommand::handle() does not exist

@basheer-atx
Copy link

I got solution

Need to change the fire function to handle in new version laravel 5.4

vendor/zizaco/entrust/src/commands/MigrationCommand.php
Line Number 35:
public function fire() to public function handle()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants