kambuku/app/Http/Controllers/ClassifiedsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        dd($id);
        dd($request);
        dd(\Request::Input());
       $classified = classifieds::whereId($id)->first();
       $image_path = Config::whereName('image_dir')->first();
       $thumb_image_path = Config::whereName('thumbnail_image_dir')->first();
        $check = 'nothing';
       $i = 0;
       while ($i <= 5)
       {
           if (isset($request['check_box_images_'.$i]))
           {
             $target =   $request['check_box_images_'.$i];
             $image = classified_images::whereFilename($target)->first();
               if ($image != null){
                   $filename = $image->filename;
                      dd($image_path->value.$filename);
                   unlink($image_path->value.$filename);
                   $image->delete();
               }
               $thumbnail = thumbnails::whereFilename($target)->first();
               if($thumbnail != null)
               {
                   $filename = $thumbnail->filename;
                   unlink($thumb_image_path->value.$filename);
                   $thumbnail->delete();
               }
           }
           $i ++;
           if (isset($request['file'.$i]))
           {
                $check = 'has';
           }
       }
        if ($check == 'has')
        {
            $request->request->add(['classified_id' => $id]);
            $this->process_images($request);
        }
       $classified->title = $request['name'];
       $classified->price = $request['price'];
       $classified->description = $request['description'];
       $classified->category_id = $request['category'];
       $classified->sub_category_id = $request['subcategory'];
       $classified->is_active = $request['is_active'];
       $classified->keywords = $request['tags'];
       $classified->condition = $request['condition'];
        $classified->save();
        Session::flash('EditedListing', 'Successfully Edited Your Listing');
        return redirect()->route('edit.product', [$id]);
    }
public function update ( Request $ request , $ id ) { $ classified = classifieds :: whereId ( $ id ) -> first ( ) ; $ image_path = Config :: whereName ( 'image_dir' ) -> first ( ) ; $ thumb_image_path = Config :: whereName ( 'thumbnail_image_dir' ) -> first ( ) ; $ check = 'nothing' ; $ i = 0 ; while ( $ i <= 5 ) { if ( isset ( $ request [ 'check_box_images_' . $ i ] ) ) { $ target = $ request [ 'check_box_images_' . $ i ] ; $ image = classified_images :: whereFilename ( $ target ) -> first ( ) ; if ( $ image != null ) { $ filename = $ image -> filename ; unlink ( $ image_path -> value . $ filename ) ; $ image -> delete ( ) ; } $ thumbnail = thumbnails :: whereFilename ( $ target ) -> first ( ) ; if ( $ thumbnail != null ) { $ filename = $ thumbnail -> filename ; unlink ( $ thumb_image_path -> value . $ filename ) ; $ thumbnail -> delete ( ) ; } } $ i ++ ; if ( isset ( $ request [ 'file' . $ i ] ) ) { $ check = 'has' ; } } if ( $ check == 'has' ) { $ request -> request -> add ( [ 'classified_id' => $ id ] ) ; $ this -> process_images ( $ request ) ; } $ classified -> title = $ request [ 'name' ] ; $ classified -> price = $ request [ 'price' ] ; $ classified -> description = $ request [ 'description' ] ; $ classified -> category_id = $ request [ 'category' ] ; $ classified -> sub_category_id = $ request [ 'subcategory' ] ; $ classified -> is_active = $ request [ 'is_active' ] ; $ classified -> keywords = $ request [ 'tags' ] ; $ classified -> condition = $ request [ 'condition' ] ; $ classified -> save ( ) ; Session :: flash ( 'EditedListing' , 'Successfully Edited Your Listing' ) ; return redirect ( ) -> route ( 'edit.product' , [ $ id ] ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// //    dd($id); //dd($request); // dd(\Request::Input()); //   dd($image_path->value.$filename);