$reqAmount = $service->price;
$useraa = auth()->user();
//$usersRl = DB::table('gift_card_services')->select('id')->get();
$usersDay1 = DB::table('gift_card_services')->select('created_at')->where('id',1)->get();
$usersDay4 = DB::table('gift_card_services')->select('created_at')->where('id',4)->get();
$usersDay7 = DB::table('gift_card_services')->select('created_at')->where('id',7)->get();
if ($useraa->username == "abdoumadris") {
// $reqAmount = ($service->price - 2);
if ($usersDay1 == "2022-10-07 19:56:20" ) {
$reqAmount = ($service->price - 2);
}
else if ($usersDay4 == "2022-10-07 19:57:20") {
$reqAmount = ($service->price - 6);
}
else if ($usersDay7 == "2022-10-07 19:59:00") {
$reqAmount = ($service->price - 10);
}else{
$reqAmount = ($service->price - 1);
}
}
i need to change the price for all product but its allways - 1
i am sure 100% that my data are set correctly and the if condition is true, but it's override to else directly
CodePudding user response:
It is a bit tricky to work with date/time. What you are comparing is a special string representation of format 'Y-m-d H:i:s'. You should check if these dates are really also stored like that in the database. This is not the way I would expect date/time to be stored.
Please give a dump of $usersDay1, $usersDay4 and $usersDay7. If these are timestamps, you might need to bring them to a different format before comparing them to string representations.