I can generate table number like this in my views index.blade.php.
<?php $no = 1; ?>
@foreach($users as $user)
<td>{{ $no }}</td>
<td>{{ $user->username }}</td>
<?php $no++; ?>
@endforeach
and my controller is UsersController.php
public function index()
{
$users = User::all();
return view('admin.user.index')->withUsers($users);
}
Yes it work, but I think this not best practice and ugly to read since views only for interface not logic. I think something like pass data from controller or maybe you can answer with your ways.
Thanks, any help appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire