app/Http/Controllers/AdsController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create_ad(Request $request)
    {    
         $ad = new Ad;
        $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 submit successfully');
    }
public function create_ad ( Request $ request ) { $ ad = new Ad ; $ 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 submit successfully' ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .