I have a table and the data is not printed, I don't know if you can help me I am a beginner the version of my Laravel is Laravel Framework 7.29.2 My controller
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function index()
{
$users = User::latest()->get();
return view('users.index', [
'users' => $users
]);
}
public function store(Request $request)
{
User::create([
'name' => $request->name,
'email' => $request->email,
'password' => $request->password,
]);
return back();
}
public function destroy(User $user)
{
$user->delete();
return back();
}
}
And my index is this, I think the error is more in the html than in anything else but I'm really not sure
<body>
<div class="container">
<div class="row">
<div class="col-sm-8 mx-auto">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Email</th>
<th>Opciones</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>Opciones</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</body>
The strange thing is that it doesn't give me any errors and if it prints the table but without data, and the database has inserted data but what I don't understand is why it doesn't call me anything.
Note that in the name of the view it is fine but that way it should work without problem
Thank you very much for the help. The final solution and that I recommend is to restart "laragon" or any manager that they have, be it xammp or another, I never knew about the error, but it was fixed by restarting laragon. I think the information was not loaded for some reason. I didn't really change anything in the code, everything was correct