本文整理汇总了PHP中app\Order::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::create方法的具体用法?PHP Order::create怎么用?PHP Order::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(OrderRequest $request)
{
$order = $request->all();
$order['user_id'] = Auth::id();
Order::create($order);
return Redirect::to("/?timer=true");
}
示例2: makeOrder
public function makeOrder(Request $request)
{
$validator = $this->validator($request->all());
if (!isset(\Auth::user()->name)) {
if ($validator->fails()) {
return redirect('order/save')->withErrors($validator)->withInput();
}
}
$input = $request->all();
$cartCollection = Cart::getContent();
$products = $cartCollection->toArray();
$productId = array_keys($products);
if (isset(\Auth::user()->name)) {
$authUser = \Auth::user();
$orderSave = Order::create(['telephone' => $authUser->telephone, 'user_name' => $authUser->name, 'email' => $authUser->email, 'adress' => $authUser->adress, 'town' => $authUser->town, 'comment' => $input['comment']]);
} else {
$orderSave = Order::create(['telephone' => $input['telephone'], 'user_name' => $input['name'], 'email' => $input['email'], 'adress' => $input['adress'], 'town' => $input['town'], 'comment' => $input['comment']]);
}
$order = Order::find($orderSave->id);
$order->product()->attach($productId);
foreach ($productId as $rm) {
Cart::remove($rm);
}
return redirect(LaravelLocalization::setLocale() . "/")->with('msg', 'Направихте успешна поръчка. Ще се свържем скоро.');
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$input = $request->all();
Order::create($input);
$request->session()->flash('flash_message', 'Order successfully added!');
return redirect()->back();
}
示例4: postOrder
public function postOrder()
{
$member_id = \Auth::user()->id;
$address = \Request::get('address');
$books_in_cart = \App\Cart::with('books')->where('member_id', '=', $member_id)->get();
$cart_total = \App\Cart::with('books')->where('member_id', '=', $member_id)->sum('total');
$order = \App\Order::create(['member_id' => $member_id, 'address' => $address, 'total' => $cart_total, 'created_at' => \Carbon\Carbon::now()]);
$message = [];
foreach ($books_in_cart as $cart_item) {
// dobavlenie v pivot
$order->orderItems()->attach($cart_item->book_id, ['amount' => $cart_item->amount, 'price' => $cart_item->books->price, 'total' => $cart_item->books->price * $cart_item->amount]);
array_push($message, $cart_item);
}
// dd($books_in_cart[0]->books->title);
// $to = 'areyoudead@inbox.ru';
// $subject = 'Tema';
// mail($to, $subject, implode($message));
// dd($message);
\Mail::send('emails.order', ['cart' => $message, 'order' => $order], function ($msg) {
// and a copy to users
$msg->to(['areyoudead@inbox.ru', \Auth::user()->email])->subject('Order');
});
//Udalyaem iz korziny vse Posle uspeshnogo dobavleniya v book_order
//To est sozdaniya zakaza i dobavleniya ego v PIVOT
\App\Cart::where('member_id', '=', $member_id)->delete();
return \Redirect::to('index')->with('message', 'Your order successfully added');
}
示例5: postBuy
/**
* agreed to buy
* @param Request
* @return [type]
*/
public function postBuy(Request $request)
{
//MENU
$mainMenu = Category::getParentMenu();
$allMenu = Category::getAllMenu($mainMenu);
//HOT PRODUCTS.
$hotProduct = Product::hotProduct();
//DISCOUNT PRODUCTS.
$discountProduct = Product::discountProduct();
if (\Session::has('giohang')) {
$data = \Session::get('giohang');
if ($request->get('account_number') != null) {
$account_number = $request->get('account_number');
} else {
$account_number = null;
}
$transaction = ['customer_id' => \Auth::id(), 'ship_id' => \Session::get('ship'), 'pay_id' => \Session::get('pay'), 'amount' => \Session::get('total'), 'message' => $request->get('message'), 'security' => time(), 'account_number' => $request->get('account_number')];
//dd($transaction);
$transactions = Transaction::create($transaction);
//dd($transactions->toArray());
foreach ($data as $key => $value) {
$order = ['transaction_id' => $transactions->id, 'product_id' => $value['id'], 'qty' => $value['qty'], 'price_order' => $value['price'], 'discount_order' => $value['discount']];
$orders = Order::create($order);
}
$this->getCancel();
return view('fornindex.shopping_succeed', compact('allMenu', 'hotProduct', 'discountProduct'));
}
}
示例6: bagStore
/**
* @param LoginCustomerFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function bagStore(LoginCustomerFormRequest $request)
{
/////////////////////// "AUTH" CLIENT ///////////////////////
$customer_name = Input::get('customer_name');
$customer_email = Input::get('customer_email');
// si username + email (provenant des inputs) match avec ceux de la bdd :
$customer = Customer::whereRaw('username = ? and email = ?', [$customer_name, $customer_email])->first();
if (!empty($customer)) {
// on envois les datas en bdd :
$order = Order::create($request->all());
// id du client :
$customer_id = $customer->id;
$order->customer_id = $customer_id;
$order->save();
// On va associer LA commande aux produits en bdd :
$paniers = Session::get("panier");
$newItems = [];
foreach ($paniers as $panier) {
$newItems[] = ['order_id' => $order->id, 'product_id' => $panier["product_id"], 'quantity' => $panier["quantity"]];
}
DB::table('order_product')->insert($newItems);
// on vide le panier :
Session::forget('panier');
return redirect(url('/'))->with('message', 'Votre commande à bien été pris en compte !');
} else {
return redirect()->back()->with('error', 'Erreur, nom d\'utilisateur ou mot de passe incorrect !');
}
}
示例7: submitOrder
public function submitOrder(Request $request)
{
$this->validate($request, ['merchandiser_id' => 'required|integer', 'trade_no' => 'required|max:255', 'subject' => 'required|max:255', 'amount' => 'required|numeric', 'returnUrl' => 'required|url', 'notifyUrl' => 'required|url', 'items' => 'array']);
$data = $request->all();
$merch = Merchandiser::where('status', 'alive')->findOrFail($data['merchandiser_id']);
if ($this->verify($data, $merch['pubkey'])) {
$order = Order::where('merchandiser_id', $merch['id'])->where('trade_no', $data['trade_no'])->first();
if (empty($order)) {
if (parse_url($data['returnUrl'], PHP_URL_HOST) != $merch['domain'] || parse_url($data['notifyUrl'], PHP_URL_HOST) != $merch['domain']) {
return $this->jsonFormat(null, 'Your URL must belongs to domain "' . $merch['domain'] . '"', '400');
}
$order = Order::create(['merchandiser_id' => $data['merchandiser_id'], 'trade_no' => $data['trade_no'], 'subject' => $data['subject'], 'amount' => $data['amount'], 'items' => serialize($data['items']), 'returnUrl' => $data['returnUrl'], 'notifyUrl' => $data['notifyUrl']]);
$order->items = unserialize($order->items);
return $this->jsonFormat($order);
} elseif ($order->status == 'pending') {
$order->update(['subject' => $data['subject'], 'amount' => $data['amount'], 'items' => serialize($data['items'])]);
$order->items = unserialize($order->items);
return $this->jsonFormat($order);
} else {
return $this->jsonFormat(null, 'trade_no already exsits', '409');
}
} else {
return $this->jsonFormat(null, 'Signature Invalid or timestamp expired', '403');
}
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
// $error = $this->validate($request, $this->rules, $this->messages);
// if ($request->ajax() && $error == Null) {
// return 'success';
// }
$input = Input::all();
$input['city_id'] = 1;
if (Auth::user()) {
$input['client_id'] = Auth::user()->id;
}
if ($input['status_id'] == '') {
$input['status_id'] = 1;
}
if ($input['payment_amount'] == '') {
$input['payment_amount'] = 0;
}
// dd($input);
$order = Order::create($input);
foreach ($input['oe'] as $oe) {
if ($oe['id'] < 0) {
$oe['order_id'] = $order->id;
$oe['status_id'] = 1;
$oe['payment'] = 0;
OrderEntry::create($oe);
}
}
return Redirect::route('admin.orders.index')->with('message', 'Orders created');
}
示例9: getCustomerNewOrder
public function getCustomerNewOrder(Request $request, Order $order, Payment $payment)
{
if ($request->ajax()) {
$customer_id = $request->input('customer_id');
$order_amount = $request->input('amount') != '' ? $request->input('amount') : 0;
$category = $request->input('category');
$balance = $payment->where('customer_id', $customer_id)->first(['account_balance']);
if ($customer_id != '' && $order_amount != '') {
if ($order_amount == 0) {
return ['message' => 'Order Amount of (' . nairaFormater($order_amount) . ') is too small!', 'title' => 'Warning!', 'type' => 'warning'];
} else {
if ($balance->account_balance >= $order_amount) {
$this->orders = $order->create(['order_amount' => $order_amount, 'order_category_id' => $category, 'customer_id' => $customer_id]);
// Deduct order amount from balance
$final_balance = $balance->account_balance - $order_amount;
$payment->where('customer_id', $customer_id)->update(['account_balance' => $final_balance]);
if ($this->orders->id) {
$order->whereId($this->orders->id)->update(['receipt_number' => thcReceiptNoGenerator($this->orders->id)]);
return ['message' => 'Your order of ' . nairaFormater($order_amount) . ' has been completed successfully!', 'title' => 'Order Complete!', 'type' => 'success', 'amount_balance' => $final_balance];
} else {
return ['message' => 'An error occurred while completing your Order!', 'title' => 'Error!', 'type' => 'error'];
}
} else {
return ['message' => 'Account Balance (' . nairaFormater($balance->account_balance) . ') is too low to complete your Order of ' . nairaFormater($order_amount) . '!', 'title' => 'Warning!', 'type' => 'warning'];
}
}
} else {
return ['message' => 'We can\'t seem to find your record!', 'title' => 'Error!', 'type' => 'error'];
}
}
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->session()->has('order_id')) {
$guest = new User();
$guest->is_guest = true;
$guest->name = 'Gast';
if ($guest->save()) {
$guestOrder = Order::create(['user_id' => $guest->id, 'status' => 0, 'city_id' => $request->session()->get('selectedCity')['id']]);
$request->session()->put('user_id', $guest->id);
$request->session()->put('order_id', $guestOrder->id);
} else {
abort(500);
}
} elseif (Auth::check()) {
$databaseOrderID = Order::where('user_id', '=', Auth::id())->where('status', '=', 0)->first();
$sessionOrderID = $request->session()->get('order_id');
if (!count($databaseOrderID)) {
$userOrder = Order::create(['user_id' => Auth::id(), 'status' => 0, 'city_id' => $request->session()->get('selectedCity')['id']]);
$this->mergeOrders($userOrder->id, $sessionOrderID, $request);
}
$databaseOrderID = Order::where('user_id', '=', Auth::id())->first();
$sessionOrderID = $request->session()->get('order_id');
if ($databaseOrderID->id != $sessionOrderID) {
$this->mergeOrders($databaseOrderID->id, $sessionOrderID, $request);
}
}
return $next($request);
}
示例11: run
public function run()
{
$faker = Faker::create();
//'ko_KR'
foreach (range(1, 20) as $index) {
Order::create(['product_name' => $faker->word, 'order_date' => $faker->dateTime, 'delivery_date' => $faker->dateTime, 'delivery_agency' => $faker->company, 'customer_name' => $faker->name, 'track_number' => $faker->randomNumber]);
}
}
示例12: run
public function run()
{
$faker = Faker::create();
$userIds = User::lists('id')->all();
foreach (range(1, 10) as $index) {
Order::create(['user_id' => $faker->randomElement($userIds), 'location' => $faker->sentence(), 'delivered_at' => $faker->dateTime(), 'delivery_status' => $faker->numberBetween(0, 10)]);
}
}
示例13: makeOrder
/**
* Обработчик запроса на заказ
*/
public function makeOrder(Request $request)
{
$this->validate($request, ['username' => 'required|max:255', 'company' => 'max:255', 'email' => 'required|email|max:255', 'phone' => 'required|max:255', 'product_title' => 'required']);
// Сохранение в БД
$order = Order::create(['username' => $request->username, 'company' => $request->company, 'email' => $request->email, 'phone' => $request->phone, 'comment' => $request->comment, 'product_title' => $request->product_title, 'status' => 1]);
// Отправка на почту с помощью событий
event(new OrderWasCreatedEvent($order));
return ['status' => 'ok'];
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Order::create(['user_id' => 1, 'total_price' => 15, 'invoice_nr' => NULL]);
Order::create(['user_id' => 2, 'total_price' => 40, 'invoice_nr' => 12345]);
Order::create(['user_id' => 2, 'total_price' => 30, 'invoice_nr' => NULL]);
Order::create(['user_id' => 2, 'total_price' => 1000, 'invoice_nr' => NULL]);
Order::create(['user_id' => 3, 'total_price' => 50, 'invoice_nr' => 12345]);
Order::create(['user_id' => 3, 'total_price' => 15, 'invoice_nr' => 666]);
Order::create(['user_id' => 3, 'total_price' => 30, 'invoice_nr' => NULL]);
}
示例15: run
public function run()
{
$faker = $this->getFaker();
$accounts = User::all();
foreach ($accounts as $account) {
for ($i = 0; $i < rand(-1, 5); $i++) {
Order::create(["user_id" => $account->id]);
}
}
}