Wednesday, March 15, 2017

Laravel: How to write resource controller methods

I've written the following:

public function show($id)
{
    $image = Image::find($id);
    $path = $image-file_path;
    return response()->file();
}

In routes/web.php I have the following:

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

Now I don't know why when I go to http://localhost:8000/image/5 in my browser, I get:

FatalErrorException in ImageController.php line 48:
Class 'App\Http\Controllers\Image' not found
in ImageController.php line 48

What can I do to fix this?



via Sandi

Advertisement