i have the following tables
- Users
- request
- servers
Which are related in the following way.
- User has many request
- Sever has many request
Now what I want is to get all the servers associated with the requests that the user has without repetitions.
I have to do it in the blade view since in the view I am iterating the services and showing them in a table.
So far I've been trying the following
@foreach($requests as $request)
@php
$serversUser = \App\Server::where('requestsofservice', function($query){
$query->where('user_id',$request->user->id);
});
@endphp
@endforeach
But it doesn't work be caouse the var $request->user->id .
and the result is Undefined variable: request
So, how could i get the services that the user a has related to their request without repetitions.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire