app/Http/Controllers/CouponController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Coupon  $coupon
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Coupon $coupon)
    {
        $request->validate([
            'coupon_name' => 'unique:products,product_name,' . $coupon->id,
            'coupon_person' => ['required'],
            'coupon_percent' => ['required','max:100'],
            'validity_date' => ['required'],
        ]);
        $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 update ( Request $ request , Coupon $ coupon ) { $ request -> validate ( [ 'coupon_name' => 'unique:products,product_name,' . $ coupon -> id , 'coupon_person' => [ 'required' ] , 'coupon_percent' => [ 'required' , 'max:100' ] , 'validity_date' => [ 'required' ] , ] ) ; $ 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' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .