samedi 12 décembre 2015

how to image update using laravel5

When I update my image file It show this error: i dont know how to edit image using laravel5

FatalErrorException in SiteadminController.php line 1719: Class 'App\Http\Controllers\Image' not found

Controller

 public function siteadmin_update_ads(Request $request)
    {


        $post = $request->all();
          $cid=$post['id'];  
         // $img=$post['ads_image'];

        $v=validator::make($request->all(),
                [
                    'ads_title'=>'required',
                    'ads_url' => 'required',

                ]
                );

        if($v->fails())
        {
            return redirect()->back()->withErrors($v->errors());
        }

         //$image = Image::find($cid);

        else 
        {
            $image = Image::find($cid);
            if($request->hasFile('ads_image'))
            {
                    $file = $request->file('ads_image');
                     $destination_path = '../assets/adsimage/';
                   $filename = str_random(6).'_'.$file->getClientOriginalName();
                   $file->move($destination_path, $filename);
                   $image->file = $destination_path . $filename;
            $data=array(

                'ads_title'=>$post['ads_title'],
                'ads_url'=>$post['ads_url'],
                'ads_image'=>$post['ads_image'],

            );
        }
        //  $image->caption = $request->input('caption');
        // $image->description = $request->input('description');
         $image->save();

        }
        // $i = DB::table('le_color')->where('id',$post['id'])->update($data);

        $i=Ads_model::update_ads($data,$cid);

            if($i>0)
            {
                Session::flash ('message_update', 'Record Updated Successfully');
                return redirect('siteadmin_manageads');
            }

        else {
 return Redirect('siteadmin_editads');

} }

Model

public static function update_ads($data,$cid)
    {
      return DB::table('le_ads')->where('id',$cid)->update($data);  
    }

View

 <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Upload Image*</label>
                                      <div class="col-md-9 col-sm-6 col-xs-12">
                                        <input type='file' id="field" class='demo left' name='ads_image' data-type='image' data-max-size='2mb'/><br>
                                        <img src="{{ url('../assets/adsimage/').'/'.$row->ads_image}}" style="height:90px;">
                                        </div>
                                      </div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire