i'm building a invoice manager app in laravel 5.6. i'm tryiing to follow the following tut:https://www.youtube.com/watch?v=h6sTdAX6yTs&list=PLVAw_4sB6qJwCloLkV1SudLR0wcgiEXay&index=2 however i get stuck with on the part where i need to display invoices in the index (8:00).
Error: Call to a member function count() on string
index.blade.php:
@extends('layouts.app')
@section('content')
<div>
<div>
<div>
<span>Invoices</span>
<a href="">Create</a>
</div>
</div>
<div>
@if(($invoices->count()))
<table>
<thead>
<th>invoice no.</th>
<th>Grand Total</th>
<th>Client</th>
<th>Invoice Date</th>
<th>Due Date</th>
<th colspan="2">Created At</th>
</thead>
<tbody>
@foreach($invoices as $invoice)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</table>
@else
<div>
<p>
No Invoices were created.
<a href="">Create now!</a>
</p>
</div>
@endif
</div>
</div>
@endsection
InvoiceController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\InvoiceProduct;
use App\Invoice;
use DB;
class InvoiceController extends Controller
{
public function index(){
$title = 'Welkom';
//return view('pages.index', compact('title'));
$invoices = DB::select('SELECT * FROM invoices');
return view('invoices.index')->with('invoices', $title);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire