May 31, 2022
2
Level 1
Coupon expiry date
am having issues with my application when i have created a coupon in the backend and give an expiry date it dosen't expire when i change the date in my database but if i change to a previous month it shows invalid but when change just few days after expiry it still shows valid of which it should expire on date given. controller code public function store(Request $request) { $request->validate([ 'name' => 'required', 'discount' => 'required', 'validity' => 'required', ]);
Coupon::insert([
'name' => strtoupper($request->name),
'discount' => $request->discount,
'validity' => $request->validity,
'created_at'=> Carbon::now(),
]);
return redirect()->back();
}
my index code
@foreach($coupons as $coupon) {{$coupon->id}} {{$coupon->name}} {{$coupon->discount}} {{Carbon\Carbon::parse($coupon->validity)->format('D, d F Y')}} @if($coupon->validity>= Carbon\Carbon::now()->format('Y-m-d')) Valid @else Invalid @endif Edit Delete @endforeachPlease or to participate in this conversation.