In this tutorial i’m going to solve “Class “Intervention\Image\ImageServiceProvider” not found” i’m using laravel 10 then i using Intervention\Image then showing error lets solve this issue in laravel 10.
composer require intervention/image
1st go to config/app.php and put below code.
put below code in provider
'Intervention\Image\ImageServiceProvider'
put below code in alisases
'Image' => 'Intervention\Image\Facades\Image'
Solution just go to below file
composer.json
"intervention/image": "^2.3",
After adding code run below update command
composer update
Next go to controller and put below function.
1st import class on your controller
use Intervention\Image\Facades\Image as Image;
public function StoreBrand(Request $request){
$request->validate([
'brand_name' => 'required',
'brand_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$image = $request->file('brand_image');
$name_gen = hexdec(uniqid()).'.'.$image->getClientOriginalExtension();
Image::make($image)->resize(300,300)->save('upload/brand/'.$name_gen);
$save_url = 'upload/brand/'.$name_gen;
Brand::insert([
'brand_name' => $request->brand_name,
'brand_slug' => strtolower(str_replace(' ', '-',$request->brand_name)),
'brand_image' => $save_url,
]);
$notification = array(
'message' => 'Brand Inserted Successfully',
'alert-type' => 'success'
);
return redirect()->route('all.brand')->with($notification);
}
šš Now image resize working properly.