本文整理汇总了PHP中app\Order::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::validate方法的具体用法?PHP Order::validate怎么用?PHP Order::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkout
public function checkout()
{
$data = ['id' => Input::get('id'), 'email' => Input::get('email'), 'firstname' => Input::get('firstname'), 'surname' => Input::get('surname'), 'country' => Input::get('country'), 'address' => Input::get('address'), 'zip_code' => Input::get('zip_code'), 'city' => Input::get('city'), 'salution' => Input::get('salution'), 'phonenumber' => Input::get('phonenumber'), 'mobilenumber' => Input::get('mobilenumber'), 'birthdate' => Input::get('birthdate'), 'payment_method' => Input::get('payment_method')];
$cart = new Cart();
if (isset($data) && is_array($data)) {
$order_data = ['user_id' => $data['id'], 'total' => $cart::total(), 'sub_total' => $cart::total(false), 'status' => 'P', 'payment_method' => $data['payment_method']];
$order = new Order();
if ($order->validate($order_data)) {
$order->user_id = $order_data['user_id'];
$order->total = $order_data['total'];
$order->sub_total = $order_data['sub_total'];
$order->status = $order_data['status'];
$order->payment_method = $order_data['payment_method'];
$create = $order->save();
if (!$create) {
return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden. Het systeem kon het niet verwerken!']);
}
if (!empty($cart::contents())) {
foreach ($cart::contents() as $item) {
$o = new Orderdata();
$o->order_id = $order->id;
$o->product_id = $item->id;
$o->product_price = $item->price;
$o->total = $cart::total();
$o->discount = $item->discount;
$o->quantity = $item->quantity;
$o->save();
}
}
\Mail::send('emails.order', ['user' => $data, 'order_id' => $order->id], function ($m) use($data, $order) {
$m->from('stijnwop@gmail.com', 'BreiShop - De beste brei artikelen van Nederland!');
$m->to($data['email'], $data['firstname'])->subject('Bestelling #' . $order->id . '! Je Breishop.com orderbevestiging!');
});
return Redirect::route('checkout_final')->with(['msg' => 'Order is succesvol verzonden!']);
}
return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden, gegevens onjuist']);
}
return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden!']);
}