app/Http/Controllers/CouponController.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(Request $request)
    {
        $this->validate($request,[
            'code'=>'string|required',
            'type'=>'required|in:fixed,percent',
            'value'=>'required|numeric',
            'status'=>'required|in:active,inactive'
        ]);
        $data=$request->all();
        $status=Coupon::create($data);
        if($status){
            request()->session()->flash('success','Coupon Successfully added');
        }
        else{
            request()->session()->flash('error','Please try again!!');
        }
        return redirect()->route('coupon.index');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'code' => 'string|required' , 'type' => 'required|in:fixed,percent' , 'value' => 'required|numeric' , 'status' => 'required|in:active,inactive' ] ) ; $ data = $ request -> all ( ) ; $ status = Coupon :: create ( $ data ) ; if ( $ status ) { request ( ) -> session ( ) -> flash ( 'success' , 'Coupon Successfully added' ) ; } else { request ( ) -> session ( ) -> flash ( 'error' , 'Please try again!!' ) ; } return redirect ( ) -> route ( 'coupon.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// return $request->all();