In my web.php file, I specify the following route:
Route::get('/{project}', 'ProjectsController@index');
In my ProjectsController, I define the public function index as follows:
use App\Project;
// ... Here is the class declaration etc.
public function index(Project $project) {
dd($project->name);
}
Currently, I have one entry in my projects table, which I can call without any problems over my eloquent model. This is my entry:
Name: sampleproject
Description: This is a test.
// And the timestamps...
When calling /sampleproject, it returns a 404 error page.
It seems like it isn´t even reaching the index function, but when I purposefully create a error like removing the use App\Project; declaration, only when calling any arbritary page except my regular routes (like /abc), it will throw an error.
So the route is processed successfully, but something stops execution of my index function.
Have I missed anything to declare a variable url properly? (I´m using Laravel 5.8, the latest version)
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UsCeh7
via IFTTT
Aucun commentaire:
Enregistrer un commentaire