app/Http/Controllers/AdsController.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)
    {
        $ad =Ad::find($id);
        $ad->user_id = $request['user_id'];
        $ad->title   = $request['title'];
        $ad->description = $request['description'];
        $ad->quantity  = $request['quantity'];
        $ad->state_id  = $request['state_id'];
        $ad->city_id   = $request['city_id'];
        $ad->address   = $request['address'];
        $ad->payment_term = $request['payment_term'];
        $ad->shipment_term = $request['shipment_term'];
        if($request->hasFile('image'))
        {
             $name=time().'-a'.$request->image->getClientOriginalName();
             $request->image->move(public_path().'/ad/', $name);  
        }
        $ad->image =$name;
        $ad->save();
        return back()->with('success','Ad edit successfully');
    }
public function update ( Request $ request , $ id ) { $ ad = Ad :: find ( $ id ) ; $ ad -> user_id = $ request [ 'user_id' ] ; $ ad -> title = $ request [ 'title' ] ; $ ad -> description = $ request [ 'description' ] ; $ ad -> quantity = $ request [ 'quantity' ] ; $ ad -> state_id = $ request [ 'state_id' ] ; $ ad -> city_id = $ request [ 'city_id' ] ; $ ad -> address = $ request [ 'address' ] ; $ ad -> payment_term = $ request [ 'payment_term' ] ; $ ad -> shipment_term = $ request [ 'shipment_term' ] ; if ( $ request -> hasFile ( 'image' ) ) { $ name = time ( ) . '-a' . $ request -> image -> getClientOriginalName ( ) ; $ request -> image -> move ( public_path ( ) . '/ad/' , $ name ) ; } $ ad -> image = $ name ; $ ad -> save ( ) ; return back ( ) -> with ( 'success' , 'Ad edit successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .