[dx] Posted May 8, 2016 Share Posted May 8, 2016 Hi, Long time ago since I was here. I'm trying to make auth option using token. I have middleware which connects to User model and check db and store data from User::where('token', $token)->first() to User's public var $user. So everything about it works fine, but now when I make some controller I want use that instance of model. If I add use App\User; it creates new instance of model, so my data from $user are set to null. How can I access old data? Best regards. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 9, 2016 Share Posted May 9, 2016 Pass the model instance to the controller constructor when you create it so that you can use that model in that controller. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now