0
votes

I want to add a user (name, email, image, multiple images ...), and I tried to resize the image and multiple images for upload very quickly we use package intervention, I execute cmd php composer require intervention/image, i added Intervention\Image\ImageServiceProvider::class and Image'=>Intervention\Image\Facades\Image::class in config/app.php, I also added use Intervention\Image\Exception\NotReadableException; and use Intervention\Image\Facades\Image; in RegisterController.php.

but its give me error Command (Store) is not available for driver (Gd)

but its give me error Command (Store) is not available for driver (Gd)

D:\wamp\www\aswaktin\vendor\intervention\image\src\Intervention\Image\AbstractDriver.php:119

RegisterController.php

protected function validator(array $data)
    {
        return Validator::make($data, [
        'name'     => ['bail','required', 'string','min:3', 'max:50','regex:/^[\pL\s\-]+$/u'],
        'email'    => ['bail','required', 'string', 'email', 'max:255', 'unique:users'],
        'telephone'=> ['bail','required','regex:/^06\d{8}$/','unique:users'],
        'password' => ['bail','required', 'string', 'min:8', 'confirmed'],
        'adressem' => ['bail','required', 'string', 'min:13','max:255'],
        'adressem' => ['bail','required', 'string', 'min:13','max:255'],
        'adresser' => ['bail','required', 'string', 'min:13','max:255'],
        'image'    => ['bail','required','mimes:jpeg,jpg,png,gif,svg','max:2048'],
        'images.*' => ['bail','required','mimes:jpeg,jpg,png,gif,svg','max:2048']
        ]);
    }
protected function create(array $data)
    { 
        //image
        $user = new User();
        //$jdate = Carbon::now();
        $request = app('request');
        if($request->hasFile('image'))
         {
        $image = $request->file('image'); 
         $url = Storage::put("user/" , $image->getClientOriginalName());
         $image = Image::make($image);
         $image->resize(250,125);
        
          $path = $request->image->store('profiles');
          $user->image = $path;
        }
        $im = $user->image;  
        //images
        $dataim = array();
         if($request->hasFile('images')) 
         {
            foreach($request->images as $file) 
            {   
                $file = Image::make($file);
                $file->resize(250,125);
                $path = $file->store('profiles'); 
                array_push($dataim,$path);
            } 
         }
        $user->images=json_encode($dataim);
        $imm =$user->images; 
        return User::create([
            'name'         => $data['name'],
            'email'        => $data['email'], 
            'password'     => Hash::make($data['password']),
            'telephone'    => $data['telephone'], 
            'country_id'   => $data['country_id'], 
            'state_id'     => $data['state_id'], 
            'autrei'       => $data['autrei'] ?? null, 
            'city_id'      => $data['city_id'], 
            'autreh'       => $data['autreh'] ?? null, 
            'adressem'     => $data['adressem'], 
            'adresser'     => $data['adresser'],
            'image'        => $im,
            'images'       => $imm
        ]);
    }
1

1 Answers

0
votes

The problem is, you’re overwriting the uploaded file instance ($file) with an Intervention instance, but then trying to call store (and UploadedFile method) on that Intervention image instance. You’ll need to use a different variable name for your Intervention image instance instance.