Well thanks to the colleagues of the forum I managed to do the join to get the data in an array as I wanted, this is the controller's method:
public function solicitudes()
{
$vacations = \DB::table('vacations')
->select('workers.name','vacations.type','vacations.date_from','vacations.date_to','vacations.observations','vacations.aceptado')
->join('workers','workers.id','=','vacations.worker_id')
->where(['vacations.aceptado' => '0']);
//dd($vacations);
return view('vacation.showvac')->with('vacations', $vacations->get());
}
with the dd this returns me:
array:10 [▼
0 => {#224 ▼
+"name": "David Pazo"
+"type": "vacacion"
+"date_from": "1970-01-01"
+"date_to": null
+"observations": "asd"
+"aceptado": 0
}
1 => {#225 ▶}
2 => {#226 ▶}
3 => {#227 ▶}
4 => {#228 ▶}
5 => {#229 ▶}
6 => {#230 ▶}
7 => {#231 ▶}
8 => {#232 ▶}
9 => {#233 ▶}
]
which is great, but when I get to the blade view, I have an if, to check if there is data or not and it does not return any data:
@if(count($vacations) > 0)
<h2 class="text-center">No hay solicitudes pendientes</h2>
@else
<table class="table table-striped table-bordered scrolling-dataTable">
<thead>
<tr>
<th>Nombre</th>
<th>Tipo</th>
<th>Fecha inicio</th>
<th>Fecha fin</th>
<th>Observaciones</th>
<th>Pendiente</th>
<th>Opciones</th>
</tr>
</thead>
<tbody>
@foreach ($vacations as $vacation => $array)
<tr>
{{$vacation}}
@foreach ($array as $item)
<td>{{$item['name']}}</td>
<td>{{$item['type']}}</td>
<td>{{$item['date_from']}}</td>
<td>{{$item['date_to']}}</td>
<td>{{$item['observations']}}</td>
<td>{{$item['aceptado']}}</td>
and it already has me crazy, because all the examples that I saw do it this way, but I do not get the data to the view if from the controller, I would appreciate any help, a community greeting!