I'm working with Laravel 5.8 to develop my project and I have added an if..else conditional statements goes like this, to my Controller:
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,
if((($request->city)=="98")&&($cartPrice >=0)&&($request->province)=="8")){
"ort_free_delivery" => 'City Free Delivery'
}elseif((($request->city)!="98")&&($cartPrice >=0)&&($request->province)!="8")){
"ort_free_delivery" => 'Country Free Delivery'
}else{
"ort_free_delivery" => '',
}
"created_at" => now(),
"updated_at" => now()
]);
But when I run this, I get this error:
syntax error, unexpected 'if' (T_IF), expecting ']'
Which is referring to this line:
if((($request->city)=="98")&&($cartPrice >=0)&&($request->province)=="8")){
So what is going wrong here? How can I solve this issue?
I would really appreciate any idea or suggestion from you guys...
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire