Hello guys, before I start, I apologize for my English.
I have a controller called AuthController, this controller just used when app have a project like link/project/{project}
In this controller i have a cosntruct, it checks the request, if ajax need to be in header an api_token, if not, just use User::where('id', Auth::id())->first()
@DEVFREY - When i see on browser the header api_token are present, but when i return a response with value ... i get NULL.
In my machine i have the same code, and i GET the api_token value.
In this case your getting first data only using first() because Auth::id would be something different than first data$this->user = User::where('id', Auth::id())->first(); try instead with below one because it getting every data which you have in database using get(),
@munazzil sorry your answer does not make sense, there is nothing wrong with $this->user = User::where('id', Auth::id())->first(); the only viable comment about that part would have been that $this->user = Auth::user(); would have had the same result and event more effective.
->first() will get you the first result if there will be more, as ID is a primary key there can only be one result, so using ->get() will let you endup with a collection with one item and you need to add a loop or pull the first.