本文整理汇总了PHP中Model_Order::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Order::validate方法的具体用法?PHP Model_Order::validate怎么用?PHP Model_Order::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Order
的用法示例。
在下文中一共展示了Model_Order::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_update
/**
* Update Order
*
* @param type $id = Order ID
*/
public function action_update($id = false)
{
if (!is_numeric($id)) {
\Response::redirect('admin/order/list');
}
// Get order to edit
if (!($order = \Order\Model_Order::find_one_by_id($id))) {
\Response::redirect('admin/order/list');
}
\View::set_global('title', 'Edit Order');
if (\Input::post('order_details', false) && \Input::post('customer_details', false)) {
try {
$fields = array('status', 'shipping_method', 'tracking_no');
$events = array();
foreach ($fields as $field) {
$config = \Config::get('details.' . $field, array());
if (isset($config[\Input::post($field)]) && $order->{$field}) {
$value = $config[\Input::post($field)];
} else {
$value = \Inflector::humanize(\Input::post($field));
}
if (isset($config[$order->{$field}])) {
$old_value = $config[$order->{$field}];
} else {
$old_value = \Inflector::humanize($order->{$field});
}
if ($order->{$field} != \Input::post($field)) {
$events[] = \Inflector::humanize($field) . ' changed. ' . $old_value . ' => ' . $value;
}
$data[$field] = \Input::post($field);
}
// Send to customer
if (\Input::post('send_to_customer_payment')) {
//echo 'send_to_customer_payment'; exit;
}
if (\Input::post('send_to_customer_shipping')) {
//echo 'send_to_customer_shipping'; exit;
}
$order->set($data);
if ($order->save() && !empty($events)) {
foreach ($events as $event) {
$order_history = Model_History::forge(array('order_id' => $order->id, 'event' => $event));
$order_history->save();
}
}
\Messages::success('Order successfully updated.');
if (\Input::post('status') == 'shipped_to_customer') {
$this->sendNoticeShipped(\Order\Model_Order::find_one_by_id($id));
}
// if(\Input::post('exit')) \Response::redirect(\Uri::create('admin/order/list'));
// \Response::redirect(\Uri::admin('current'));
} catch (\Database_Exception $e) {
\Messages::error('<strong>' . 'There was an error while trying to update order.' . '</strong>');
}
// }
// if(\Input::post('customer_details', false))
// {
$val = Model_Order::validate('update');
if ($val->run()) {
try {
$order->set(\Input::post());
if ($order->save()) {
$order_history = Model_History::forge(array('order_id' => $order->id, 'event' => 'Customer details edited.'));
$order_history->save();
// \Messages::success('Order successfully updated.');
if (\Input::post('exit')) {
\Response::redirect(\Uri::create('admin/order/list'));
}
\Response::redirect(\Uri::admin('current'));
}
} catch (\Database_Exception $e) {
\Messages::error('<strong>' . 'There was an error while trying to update order.' . '</strong>');
}
} else {
// Delete uploaded images if there is news saving error
if (isset($this->_image_data)) {
foreach ($this->_image_data as $image_data) {
$this->delete_image($image_data['saved_as']);
}
}
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to update member</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
}
}
if (\Input::post('upload_type', false) && \Input::post('upload', false)) {
$this->uploads($id);
}
if (\Input::post('order_edit', false)) {
$post = \Input::post();
\Messages::success('Order successfully updated.');
//.........这里部分代码省略.........