0

我安装了“作曲家需要干预/图像”...添加到 config/app.php

提供者:Intervention\Image\ImageServiceProvider::class,别名:'Image' => Intervention\Image\Facades\Image::class,

然后在我的路线上我有这个:

Route::get('/thread/{img}', 'ThreadController@mostrarImagen');

在我的 ThreadController.php 上:

进口:

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Thread;
use App\Subboard;
use Image;
use Illuminate\Support\Facades\Response;

功能:

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;
}

收到此错误:

BadMethodCallException in Builder.php line 2345: Call to undefined method Illuminate\Database\Query\Builder::encode()

编辑:从这个网站http://www.core45.com/using-database-to-store-images-in-laravel-5-1/得到了例子,我有什么遗漏吗?

4

1 回答 1

0

我解决了它,正在编码我的类而不是图像,它是

$response = Response::make( $imagen ->encode('jpeg'));

于 2016-06-19T09:17:47.130 回答