Answer the question
In order to leave comments, you need to log in
What is the correct way to output data from a nested foreach loop?
There is a function:
//Получаем список клиентов и их предпочтения
protected function get_clients()
{
$result = DB::select("SELECT * FROM users as u left JOIN clients2adverts as c on u.id = c.id_client
left JOIN adverts as a ON c.id_adverts = a.id_realty
WHERE c.lead = 1 and u.activated = 1 or u.id_role = 2");
return $result;
}
<h3>Клиенты</h3><br>
@foreach($clients as $client)
<div class="table table-bordered">
<strong>ФИО</strong><br>
{{$client->surname}} {{$client->name}} {{$client->patronymic}}<br>
<strong>Предпочтения</strong><br>
<p>
Название:{{$client->title}} <br>
Город: {{$client->city}} <br>
Количество комнат:{{$client->quantity_room}} <br>
Описание: {{$client->description}} <br>
Цена: {{$client->price}}
</p>
<strong> Контакты </strong><br>
{{$client->phone}}
</div>
@endforeach
Answer the question
In order to leave comments, you need to log in
We take a one-to-many connection, get {{$client->obyavleniya}} in the view and iterate through foreach. By the way, mutators can display the full name of one variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question