When Using ->get() in your eloquent query like this :
Here you need to use a query that retrieve only the single row from the database ,like this :
User::where('userid',$userid)->get();
You are asking the database to bring all the users with the same userid and the result is a collection of results, So you need to go through all the results using foreach, even you know that in your database there is a unique user with such an id you will get a collection .
Here you need to use a query that retrieve only the single row from the database ,like this :
User::where('userid',$userid)->first();
No comments:
Post a Comment