I want List all my Users in an Table, per line one Username.
But i get only the first User in this Table , all other Users are side by side.
My Blade:
<table class="table table-hover">
<thead>
<th>Username</th>
<th>Orders</th>
<th>Balance</th>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{$user->username}} </td>
<td>{{$user->purchases}} </td>
<td>{{$user->balance}} </td>
</tr>
</tbody>
</table>
Controller:
public function ShowUserlist(){
$users = User::all();
return view('profile.dashboard', compact('users'));
}
The First User from my DB is in the <table class="table table-hover">
the other ones looks like: testtesttesttesttesttesttesttest under the Table.
How can i sort it per User one Line?
Thanks
You need to close the @foreach after each tr tag
<table class="table table-hover">
<thead>
<th>Username</th>
<th>Orders</th>
<th>Balance</th>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{$user->username}} </td>
<td>{{$user->purchases}} </td>
<td>{{$user->balance}} </td>
</tr>
@endforeach
</tbody>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With