I installed "composer require intervention/image"... added on config/app.php
providers: Intervention\Image\ImageServiceProvider::class, aliases: 'Image' => Intervention\Image\Facades\Image::class,
then on my routes I have this:
Route::get('/thread/{img}', 'ThreadController@mostrarImagen');
on my ThreadController.php:
Imports:
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Thread;
use App\Subboard;
use Image;
use Illuminate\Support\Facades\Response;
Function:
public function mostrarImagen($id) {
$thread = Thread::findOrFail($id);
$imagen = Image::make($thread->thrImg);
$response = Response::make($thread->encode('jpeg'));
$response->header('Content-Type', 'image/jpeg');
return $response;
}
getting this error:
BadMethodCallException in Builder.php line 2345: Call to undefined method Illuminate\Database\Query\Builder::encode()
EDIT: got the example from this website http://www.core45.com/using-database-to-store-images-in-laravel-5-1/, is there something i'm missing?
encode
on your model? – lagboxencode
on your model.$thread = Thread::findOrFail($id);
is a model.$thread->encode('jpeg');
is callingencode
on your model. – lagbox