I have built an eloquent query for inner join of two tables. I am getting data from the database, debugged using dump($ordered_books);
function fetchData()
{
$ordered_books = DB::table('ordered_books')
-> join('books', 'books.id','=','ordered_books.BookID')
-> select('books.BookName', 'ordered_books.BilledNum','ordered_books.BilledDate','ordered_books.Qunatity',
'ordered_books.Price', 'ordered_books.BillPaid', 'ordered_books.Remarks' )
-> get()->toArray();
dump($ordered_books);
return compact('ordered_books');
}
But when I pass the data to view page, I am getting error:
Cannot use object of type stdClass as array
How to solve this error?
View page block
@foreach($ordered_books as $data)
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
@if($data['BillPaid'] === 1)
<td>PAID</td>
@else
<td style="color:red">DUE</td>
@endif
<td> </td>
</tr>
@endforeach
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ocyaDo
via IFTTT
Aucun commentaire:
Enregistrer un commentaire