kambuku/app/Http/Controllers/ClassifiedsController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Requests\ClassifiedListingValidator $request)
    {
        $user = Auth::user()['id'];
        $classifieds = $this->create_classified($request, $user);
        $classified_id = $classifieds->id;
        $request->request->add(['classified_id' => $classified_id]);
        $counter = 0;
        $check = '';
        while($counter <= 5)
        {
            if (isset($request['file'.$counter])){
                $check = 'checked';
            }
            $counter++;
        }
        if ($check == '')
        {
            $listing = classifieds::whereId($request->classified_id)->first();
            $listing->image_path = 'placeholder.jpg';
            $listing->save();
            Session::flash('savedListing', 'Successfully Saved Your Listing');
            return redirect(route('profile'));
        }else{
            return $this->process_images($request);
        }
    }
public function store ( Requests \ ClassifiedListingValidator $ request ) { $ user = Auth :: user ( ) [ 'id' ] ; $ classifieds = $ this -> create_classified ( $ request , $ user ) ; $ classified_id = $ classifieds -> id ; $ request -> request -> add ( [ 'classified_id' => $ classified_id ] ) ; $ counter = 0 ; $ check = '' ; while ( $ counter <= 5 ) { if ( isset ( $ request [ 'file' . $ counter ] ) ) { $ check = 'checked' ; } $ counter ++ ; } if ( $ check == '' ) { $ listing = classifieds :: whereId ( $ request -> classified_id ) -> first ( ) ; $ listing -> image_path = 'placeholder.jpg' ; $ listing -> save ( ) ; Session :: flash ( 'savedListing' , 'Successfully Saved Your Listing' ) ; return redirect ( route ( 'profile' ) ) ; } else { return $ this -> process_images ( $ request ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dd($request); //dd($request->toArray());