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)
    {
    $request->validate([
        'coupon_name' => ['required','min:3','unique:coupons'],
        'coupon_person' => ['required'],
        'coupon_percent' => ['required','max:100'],
        'validity_date' => ['required'],
    ]);
    $coupon = new Coupon;
    $coupon->coupon_name = $request->coupon_name;
    $coupon->coupon_person = $request->coupon_person;
    $coupon->coupon_percent = $request->coupon_percent;
    $coupon->validity_date = $request->validity_date;
    $coupon->save();
    return back()->with('success','Data Inserted Successfully');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'coupon_name' => [ 'required' , 'min:3' , 'unique:coupons' ] , 'coupon_person' => [ 'required' ] , 'coupon_percent' => [ 'required' , 'max:100' ] , 'validity_date' => [ 'required' ] , ] ) ; $ coupon = new Coupon ; $ coupon -> coupon_name = $ request -> coupon_name ; $ coupon -> coupon_person = $ request -> coupon_person ; $ coupon -> coupon_percent = $ request -> coupon_percent ; $ coupon -> validity_date = $ request -> validity_date ; $ coupon -> save ( ) ; return back ( ) -> with ( 'success' , 'Data Inserted Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .