Jump to content

Laravel 5 - Accessing model from any controller


[dx]

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...