Я создаю index.blade.php в view / back / client для отображения списка клиентов. Но у меня возникает эта ошибка.
Неопределенная переменная: clients (View: C: \ wamp \www \ myLSF \ resources \ views \ back \ clients \ index.blade.php)
вот мой index.blade.php
<table id="example1" class="table table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th>First Name </th>
<th>Last Name</th>
<th>Address</th>
<th>Postal Code</th>
<th>City</th>
<th>Province</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
@foreach($clients as $client)
<tr>
<td>{{ $client->id }} </td>
<td>{{ $client->firstname }}</td>
<td>{{ $client->lastname }}</td>
<td>{{ $client->address }}</td>
<td>{{ $client->postalcode }}</td>
<td>{{ $client->city }}</td>
<td>{{ $client->province }}</td>
<td>{{ $client->phoneno }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th>First Name </th>
<th>Last Name</th>
<th>Address</th>
<th>Postal Code</th>
<th>City</th>
<th>Province</th>
<th>Phone</th>
</tr>
</tfoot>
</table>
вот мой clientcontroller.php
class clientController extends Controller
{
public function list()
{
$clients = client::get();
return view('/back/clients/index', compact('clients'));
}
}
вот моя модель client.php
class client extends Model
{
use Notifiable;
@var
protected $table='clients';
protected $fillable=
['firstname','lastname','address','postalcode',
'city','province','phoneno'];
}
здесь я задаю маршрут для этого в web.php
Route::name('clients')->get('clients', 'clientController@list');