I'm using the Intervention Image ( http://image.intervention.io/ ) package and using its Laravel integration. As stated in the document ion I have added the following to the service provider:
Intervention\Image\ImageServiceProvider::class
and added the following aliases to the facades
'Image' => Intervention\Image\Facades\Image::class
In my controller I'm doing just as the documentation states:
// 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());
But I'm getting this error:
ErrorException: Call to undefined method Illuminate\Database\Query\Builder::image()
Edit:
It might be a possible conflict in class names? I also have a model called Image so I think it might have something to do with that
// 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());
Yes, it's a class name conflict. You can use this:
$thumb = \\Intervention\\Image\\Facades\\Image::make('images/' . $date . "/" . $request->file->hashName());
and delete use Image;
or use Intervention\\Image\\Facades\\Image;
in your code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.