Wednesday, March 15, 2017

Laravel: Using resource controller correctly

I have a bunch of photos located in public/test_images.

I created a controller to handle image requests. I did it like this:

In routes/web.php, I wrote the line:

Route::resource('image', 'ImageController');

And in the terminal I wrote:

php artisan make:controller ImageController --resource

Now I have the ImageController file in app/Http/Controllers.

My goal is to be able to do this:

http://localhost:8000/image/5

and then get an image returned. But this doesn't work. I get nothing returned. Same thing if I just write http://localhost:8000/image. What am I doing wrong?



via Sandi

Advertisement