i want to select all services rows from servs table _____ i have two tables users
with model(User) ..... and servs
with model(servs) ... . uwant to select all rows from servs when it auth User How can i do that ???
public function postserv(){
$serv = User::find(Auth::user()->id)->servs;
$serv = $serv->first();
return $serv->serv_id;
}
I'm not sure of the model name, but it should be something like Serv::all()
Your question is very vague and it's hard to determine what's going on in your project but I'll give it a shot.
If you want to select all rows of a model use the following: Services::all()
Whilst that is what you're explicitly asking for, your question seems to pertain to a relationship where you select all services for a user. User::find(Auth::user()->id)->servs()->get();
This will return all services that are joined to the authorised user, on the note of naming conventions you should make your relations more readable. Also note that you must have your relationships set up in your Eloquent models else the above code would fail.
In future try to add a little more detail for your questions, there is more information about relationships in the Eloquent ORM on the Laravel website.
ModelName::all();
Returns all rows from a model/table.