I installed intervention image using composer.phar require intervention/image . Adding the 'Image' => Intervention\Image\Facades\Image::class, in aliases and Intervention\Image\ImageServiceProvider::class, in 'providers' in config/app.php.
But still Class "App\Http\Controllers\Image" not found.
If I write use Image; on the top of the controller then this happen : GD Library extension not available with this PHP installation. To solve it I uncommented the extension=gd in the php.ini file. But nothing change.
Pls can you tell me ,where I am wrong.
This is my code :
public function Store(Request $req){
//validation
$validation = $req->validate([
'brand_name' => 'required|unique:brands|min:3',
'brand_image' => 'required|mimes:jpg,jpeg,png'
]);
//file name and store
$brand_image = $req->file('brand_image');
$name_gen = hexdec(uniqid()).".".$brand_image->getClientOriginalExtension();
Image::make($brand_image)->resize(300,200)->save('image/brand/'.$name_gen);
$storingToDatabase = 'image/brand/'.$name_gen;
//Insertion
$brand = new Brand();
$brand->brand_name = $req->brand_name;
$brand->brand_image= $storingToDatabase;
$brand->created_at = Carbon::now();
$brand->save();
return back()->with('success','Image inserted successfully');
}
CodePudding user response:
You just can keep using Image
in your controller, but by adding at the beginning
use Intervention\Image\Facades\Image;
That will make use of the Intervention package instead.