I want to write these if..else statements with ternary operators:
if((($request->city)=="98")&&($cartPrice >= 300000)&&($request->province)=="8")){
"ort_free_delivery" => 'City sending free delivery'
}elseif((($request->city)!="98")&&($cartPrice >=300000)&&($request->province)!="8")){
"ort_free_delivery" => 'Country sending free delivery'
}else{
"ort_free_delivery" => '',
}
And here is my try:
( ( ($request->city)=="98" ) ? ($cartPrice>=300000) ? ( ( ($request->province)=="8" ) ? "ort_free_delivery" == "City sending free delivery" ) );
( ( ($request->city)!="98" ) ? ($cartPrice>=300000) ? ( ( ($request->province)!="8" ) ? "ort_free_delivery" == "Country sending free delivery" : "ort_free_delivery" == "" ) );
But this is wrong because there are two lines of ternary operators, and I need this condition in one line (because I'm inserting some data with DB class in Laravel):
DB::table('order_detail')->insert([
"ort_ord_id" => $orderId,
"ort_amount" => $value->price,
"ort_total" => $value->discounted * $value->quantity,
"ort_discount" => ($value->price * $value->quantity) - $value->discounted * $value->quantity,
"ort_type" => "product",
"ort_number" => $value->quantity,
"ort_reference_id" => $value->id,
( ( ($request->city)=="98" ) ? ($cartPrice>=300000) ? ( ( ($request->province)=="8" ) ? "ort_free_delivery" == "City sending free delivery" ) )
( ( ($request->city)!="98" ) ? ($cartPrice>=300000) ? ( ( ($request->province)!="8" ) ? "ort_free_delivery" == "Country sending free delivery" : "ort_free_delivery" == "" ) )
"created_at" => now(),
"updated_at" => now()
]);
So my question is, how can I add this conditional statement with ternary operators in one line?