if (Request::ajax())
{
$orderItemData = Input::except('_method', '_token');
if (array_key_exists('registered_no', $orderItemData))
**{**
$orderItemData['status'] = ($orderItemData['registered_no'] != '' ? 'arrived' : null);
OrderItem::where('id', $orderItemId)->update($orderItemData);
return Response::json(array('success' => 1, 'data' => $orderItemData));
**}**
}
This code works fine without the { } i bold above. Any idea why ? I'm trying to do a elseif but i cant because i cant put the { } the code will fail(It doesn't response)
This:
if (condition)
action
anotherAction
will run anotherAction
even if condition
was false. But:
if (condition)
{
action
anotherAction
}
will not run either of the actions if condition
was false. It is up to you which actions you want executed - include them in the { .. }
block and leave the rest out.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.