From the controller I execute the following query:
$pruebas = DB::select( DB::raw("SELECT
t1.id,
t2.name AS 'Type',
t4.company AS 'Company',
t4.name AS 'clientName',
t4.lastname AS 'clientLastName',
t4.email AS 'Contact',
t3.name AS 'Status',
t1.created_at,
t1.'when' FROM quotation t1
JOIN quotation_type t2 ON t1.id_quotation_type = t2.id
jOIN quotation_status_type t3 ON t1.id_quotation_status_type = t3.id
JOIN client t4 ON t1.id_client = t4.id") );
return view('home')->with("pruebas", $pruebas);
I want to load the data obtained in a table but I get the following error:
Object of class stdClass could not be converted to string (View: /Users/Hernan/Desktop/BRAVALL/project/resources/views/home.blade.php)
In the html it is by default the table and I do not understand what the problem is, please help:
@if(count($pruebas) > 0)
<table class="table table-bordered table-hover" id="myTable">
<thead>
<tr>
<th>ID</th>
<th>Tipo</th>
<th>Empresa</th>
<th>Cliente</th>
<th>Contacto</th>
<th>Estado</th>
<th>Fechaa</th>
<th>Fechab</th>
</tr>
</thead>
<tbody>
@if (count($pruebas)) @foreach ($pruebas as $prueba)
<tr>
<td><a href="/quotedetail?data=<?echo urlencode("$prueba");?>">#{{ $prueba->id }}</a></td>
<!-- <td><a href="/provider?data={{$prueba}}">#{{ $prueba->id }}</a></td> -->
<td>{{ $prueba->Type }}</td>
<td>{{ $prueba->Company }}</td>
<td>{{ $prueba->Client }}</td>
<td>{{ $prueba->Contact }}</td>
<td>{{ $prueba->Status }}</td>
<td>{{ $prueba->created_at }}</td>
<td>{{ $prueba->when }}</td>
</tr>
@endforeach @else
<h1>No hay registros</h1>
@endif
</tbody>
</table>
@else
<div class="alert alert-danger">
No se encontrarón registros
</div>
@endif
The returning array is as follows: