本文整理匯總了PHP中app\models\Item::saveItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::saveItem方法的具體用法?PHP Item::saveItem怎麽用?PHP Item::saveItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Item
的用法示例。
在下文中一共展示了Item::saveItem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postAddUpdateItem
/**
* Save & Update item
*
* @return json
*/
public function postAddUpdateItem()
{
if (\Request::ajax()) {
try {
$data = \Request::all();
unset($data['_token']);
$saved_item_id = 0;
$affected_rows = 0;
$item = new Item();
// item_id will be empty while adding new item (Save item)
// item_id will not be empty while updating item (Update item)
if (!empty($data['item_id'])) {
$affected_rows = $item->updateItem($data);
} else {
$saved_item_id = $item->saveItem($data);
}
if ($saved_item_id > 0) {
return Response::json(array('success' => 1, 'msg' => 'The item has been added !'));
} elseif ($affected_rows > 0) {
return Response::json(array('success' => 1, 'msg' => 'Item details have been saved !'));
} else {
return Response::json(array('success' => 0, 'msg' => 'Error Occurred while saving item !'));
}
} catch (\Exception $e) {
return Response::json(array('success' => 0, 'msg' => 'Error Occurred !'));
}
}
}