本文整理匯總了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!']);
}