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

How to access current user in a CrudController #20

Closed
iwillhappy1314 opened this issue Sep 23, 2016 · 3 comments
Closed

How to access current user in a CrudController #20

iwillhappy1314 opened this issue Sep 23, 2016 · 3 comments

Comments

@iwillhappy1314
Copy link

I can use @role('admin') in templates, but when a access current user by Auth::User() method, it returns Null, how can I access it, and use $user->hasRole('writer') in a CrudController ?

@tabacitu
Copy link
Member

Hi @iwillhappy1314 ,

Starting with 5.3, Laravel no longer provides session access in constructors. And that's where the auth information is stored.

This would be a solution: Laravel-Backpack/CRUD#95 (comment)

Cheers!

@tabacitu
Copy link
Member

Starting with Backpack\CRUD 3.1.24 you should be able to rename your __construct() into setup() and be able to use that.

P.S. I'll go ahead and close this issue so we don't clog the section. Feel free to open it again if you encounter problems or comment if you have follow-ups.

@iwillhappy1314
Copy link
Author

got it, thanks!

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

2 participants