Php Laravel 5.4和对未定义方法Illumb\Database\Query\Builder::Image()的干预图像调用
我正在使用Intervention Image()包,并使用它的Laravel集成。如文件所述,我已向服务提供商添加以下内容:Php Laravel 5.4和对未定义方法Illumb\Database\Query\Builder::Image()的干预图像调用,php,laravel,Php,Laravel,我正在使用Intervention Image()包,并使用它的Laravel集成。如文件所述,我已向服务提供商添加以下内容: Intervention\Image\ImageServiceProvider::class 并将以下别名添加到立面 'Image' => Intervention\Image\Facades\Image::class 在我的控制器中,我正在执行文档中所述的操作: // Create a thumbnail for the image $thu
Intervention\Image\ImageServiceProvider::class
并将以下别名添加到立面
'Image' => Intervention\Image\Facades\Image::class
在我的控制器中,我正在执行文档中所述的操作:
// Create a thumbnail for the image
$thumb = Image::make('images/' . $date . "/" . $request->file->hashName());
$thumb->resize(320, 240);
$thumb->save('images/' . $date . "/thumb_" . $request->file->hashName());
但我得到了一个错误:
ErrorException: Call to undefined method Illuminate\Database\Query\Builder::image()
编辑:
类名中可能存在冲突?我也有一个叫做Image的模型,所以我认为它可能与此有关
// Save the image details to the database
$image = new Image;
$image->filename = $request->file->hashName();
$image->path = 'images/' . $date;
$image->album_id = $request->id;
$image->save();
// Create a thumbnail for the image
$thumb = Image::make('images/' . $date . "/" . $request->file->hashName());
$thumb->resize(320, 240);
$thumb->save('images/' . $date . "/thumb_" . $request->file->hashName());
是的,这是一个类名冲突。您可以使用以下选项:
$thumb=\Intervention\Image\Facades\Image::make('images/'.$date./'$request->file->hashName())代码>
删除使用图像代码>或使用干预\Image\Facades\Image代码>在您的代码中