I am trying to figure out why my route is throwing a 404 error rather than providing my image. I am using Spatie media library to serve private images.
I have the following routes web.php:
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::middleware(['auth'])->group(function () {
Route::get('/images/{$gift}/{$uuid}', 'ImageController@show')->name('images.show');
Route::resource('games', 'GameController');
Route::resource('players', 'PlayerController');
});
Route::get('/', function () {
return view('welcome');
});
When I do this: {{ route('images.show', [$gift, $gift->getFirstMedia()->uuid]) }}
in my blade, the URL is correctly generated. However, clicking on the link results in a 404 error.
The ImageController@show function exists, and currently does nothing more than dd('here');
so I am sure that Laravel is never even attempting to call the function.
Also, there is nothing currently in my laravel.log file. This 404 error does not generate a log entry.
Thank you for your assistance!
When defining route parameters in the URI they are just names, they are not PHP variables:
Should be: