class StudentsController extends Controller {
public function retrievedata()
{
return view('test', [
'students' => Student::all()
]);
}
}
and do not forget to connect the student model in the use block
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I just created a table students using make:migration and then migrate to database. I inserted data in students table manually.
Now i want to retrieve that data in laravel using mvc pattern.
I have 1 controller StudentController, 1 Model class Student, 1 view test.blade.php
I also defined route in web.php as follow Route::get('test', 'StudentsController@retrievedata');
StudentController as follow
Please or to participate in this conversation.