When I click the link leading to /[page]/ffacts
, where [page]
is one of zagor
, dylan_dog
or superman
, I get a blank page.
The view is in resource/views/[page]/ffacts.blade.php
These are the routes:
Route::get('/', 'PagesController@home');
Route::resource('zagor', 'ZagorController');
Route::resource('dylan_dog', 'DylanDogController');
Route::resource('superman', 'SupermanController');
Route::get('/zagor/ffacts', 'ZagorController@ffacts');
Route::get('/dylan_dog/ffacts', 'DylanDogController@ffacts');
Route::get('/superman/ffacts', 'SupermanController@ffacts');
Code in Controllers:
public function ffacts()
{
return view('Superman.ffacts', compact('superman'));
}
Change it like this:
Route::get('/', 'PagesController@home');
Route::get('/zagor/ffacts', 'ZagorController@ffacts');
Route::resource('zagor', 'ZagorController');
Route::get('/dylan_dog/ffacts', 'DylanDogController@ffacts');
Route::resource('dylan_dog', 'DylanDogController');
Route::get('/superman/ffacts', 'SupermanController@ffacts');
Route::resource('superman', 'SupermanController');
Problem is, that /zagor/ffacts
get matched by Route::resource('zagor', 'ZagorController');
because resource
generate all routes for all CRUD operations, so also something like this /zagor/{id}
And this is matched before your custom. You can also check this by running artisan command: php artisan route:list
From what I can see, if your directory structure is really
resource/views/page/ffacts.blade.php
then you will need to be using the following return command for the view
public function ffacts()
{
return view('page.ffacts', compact('superman'));
}
To use return view('Superman.ffacts')
you would need a directory structure of resources/views/Superman/ffacts.blade.php