本文整理汇总了PHP中app\Order::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::select方法的具体用法?PHP Order::select怎么用?PHP Order::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::select方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$users = User::select('id')->get();
$products = Product::select('id')->get();
$categories = Category::select('id')->get();
$areas = Area::select('id')->get();
$orders = Order::select('id')->get();
return view('admin.dashboard', compact('users', 'products', 'categories', 'areas', 'orders'));
}
示例2: datatables
public function datatables()
{
$orders = Order::select(["id", "cart_id", "user_id", "created_at"]);
return Datatables::of($orders)->addColumn('action', function ($model) {
return '<a href="#modal-edit" data-order-id="' . $model->id . '" data-id="' . $model->cart->id . '" class="btn btn-xs btn-primary btn-passengers"><i class="glyphicon glyphicon-zoom-in"></i> Passengers</a>' . '<a href="#modal-payment" data-order-id="' . $model->id . '" data-id="' . $model->cart->id . '" class="btn btn-xs btn-success btn-payment"><i class="glyphicon glyphicon-zoom-in"></i> Billings</a>' . '<a href="#modal-edit" data-order-id="' . $model->id . '" data-id="' . $model->cart->id . '" class="btn btn-xs btn-default btn-passengers"><i class="glyphicon glyphicon-pencil"></i></a>';
})->editColumn('cart_id', function ($model) {
return $model->payment();
})->editColumn('user_id', function ($model) {
return $model->user->first_name . " " . $model->user->last_name;
})->make(true);
}
示例3: archive
public function archive(Request $request)
{
if ($request->ajax()) {
$orders = Order::select('*')->whereStatus("3")->with("customer")->get();
return Datatables::of($orders)->editColumn('order_id', function ($order) {
return '<a href="/order/' . $order->id . '/show">' . $order->order_id . '</a>';
})->editColumn('name', function ($order) {
return '<a href="/customer/' . $order->customer->id . '/show">' . $order->customer->name . '</a>';
})->editColumn('started_at', function ($order) {
return $order->startedAt();
})->editColumn('finished_at', function ($order) {
return $order->finishedAt();
})->make(true);
}
$html = $this->htmlBuilder->addColumn(['data' => 'order_id', 'name' => 'order_id', 'title' => 'Ordernr'])->addColumn(['data' => 'name', 'name' => 'name', 'title' => 'Kund'])->addColumn(['data' => 'started_at', 'name' => 'started_at', 'title' => 'Påbörjad'])->addColumn(['data' => 'finished_at', 'name' => 'finished_at', 'title' => 'Avslutad']);
return view('archive.archive', compact('html'));
}
示例4: order
public function order($id, OrderFormRequest $request)
{
$receiver_name = $request->input('receiver_name');
$address = $request->input('address');
$phone = $request->input('phone');
$email = $request->input('email');
$received_date = $request->input('received_date');
//
$result = Order::create(['user_id' => $id, 'receiver_name' => $receiver_name, 'received_date' => $received_date, 'address' => $address, 'phone' => $phone, 'email' => $email]);
if (count($result) > 0) {
$items = Cart::content();
$ordered_id = Order::select('id')->orderBy('id', 'desc')->first();
foreach ($items as $item) {
OrderDetail::create(['ordered_id' => $ordered_id->id, 'user_id' => $id, 'product_id' => $item->id, 'quantity' => $item->qty, 'price' => $item->price]);
$update_quantity = Product::find($item->id);
$update_quantity->update(['quantity' => $update_quantity->quantity - $item->qty]);
}
}
Cart::destroy();
return redirect()->route('completed');
}
示例5: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
if (!isset($_GET['status'])) {
$status = "NULL";
} else {
$status = "'" . $_GET['status'] . "'";
}
$user = Auth::user();
$user_type = $user->user_type;
if ($user_type == 'COMPANY') {
$id_company = $user->id_company;
$id_user = "NULL";
} else {
$id_company = Session::get('id_company');
if ($id_company == null) {
redirect('estabelecimentos');
}
$id_user = $user->id_user;
}
$orders = Order::select('id_order', 'table', 'hash_card', 'products.product_name', 'quantity', 'order_status', 'orders.created_at', 'orders.id_user', 'orders.id_company')->leftJoin('products', 'orders.id_product', '=', 'products.id_product')->whereRaw("orders.order_status = COALESCE({$status}, orders.order_status)\n \t\t\t\tAND orders.id_user = COALESCE({$id_user}, orders.id_user)\n \t\t\t\tAND orders.id_company = COALESCE({$id_company}, orders.id_company)")->orderBy('id_order', 'ASC')->get();
return view('pedidos.index', compact('orders'));
}
示例6: moveFromOrder
/**
* Removes the selected item from the cart, and stores it back in the Later Cart
*
* @param int $origin type of the origin order ('cart','later',etc)
* @param int $destination type of the destination order ('cart','later',etc)
* @param int $productId of the product
* @return Redirects back to de cart
*/
public function moveFromOrder($origin, $destination, $productId)
{
/**
* validating if the product requested is valid.
* if it fails, there will be an 404 exception threw
*/
try {
$product = Product::findOrFail($productId);
} catch (ModelNotFoundException $e) {
throw new NotFoundHttpException();
}
$user = \Auth::user();
/**
* $originType allows tracking the type of origin, if it is coming from a specific wish list
* @var string
*/
$originType = '';
//if it came from a specific wish list
if ($origin != 'later' && $origin != 'cart' && $origin != 'wishlist' && is_string($origin)) {
//getting the list type
$originType = Order::select(['id', 'type'])->where('description', 'LIKE', $origin)->first();
//getting the list information
$basicCart = Order::ofType($originType->type)->where('user_id', $user->id)->where('id', $originType->id)->first();
} else {
//getting the list information
$basicCart = Order::ofType($origin)->where('user_id', $user->id)->first();
}
//getting information of the destination order
$destinationOrder = Order::ofType($destination)->where('user_id', $user->id)->first();
//if there is not destination, it is created
if (!$destinationOrder) {
$destinationOrder = new Order();
$destinationOrder->user_id = $user->id;
$destinationOrder->type = $destination;
$destinationOrder->status = 'open';
$destinationOrder->save();
$log = Log::create(['action_type_id' => '1', 'details' => $destinationOrder->id, 'source_id' => $destinationOrder->id, 'user_id' => $user->id]);
}
//checking if the user already has a product in the origin order, if so, it can be read to update the destination order.
$originDetail = OrderDetail::where('order_id', $basicCart->id)->where('product_id', $product->id)->first();
if ($originDetail) {
$oldQuantity = $originDetail->quantity;
$originDetail->delete();
} else {
$oldQuantity = 1;
}
//checking if the product exist in the destination, if so, it can be updated
$orderMoved = OrderDetail::where('order_id', $destinationOrder->id)->where('product_id', $product->id)->first();
//creating the new orden
if ($orderMoved) {
$orderMoved->price = $product->price;
$orderMoved->quantity = $orderMoved->quantity + $oldQuantity;
} else {
$orderMoved = new OrderDetail();
$orderMoved->order_id = $destinationOrder->id;
$orderMoved->product_id = $product->id;
$orderMoved->price = $product->price;
$orderMoved->quantity = $oldQuantity;
$orderMoved->status = 1;
}
//save new order
$orderMoved->save();
if ($product->type != 'item') {
$virtual = VirtualProduct::where('product_id', $product->id)->first();
//updating the virtual product order
VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('order_id', $basicCart->id)->update(['order_id' => $destinationOrder->id]);
}
if ($destination == 'later') {
Session::push('message', trans('store.productSavedForLater'));
} elseif ($destination == 'cart') {
Session::push('message', trans('store.productAdded'));
}
return redirect()->route('orders.show_cart');
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$cards = Card::find($id);
$hash_card = $cards['hash_card'];
$orders = Order::select('id_order', 'order_status', 'table', 'hash_card', 'products.product_name', 'quantity', 'products.price', 'orders.created_at')->where('hash_card', '=', $hash_card)->leftJoin('products', 'orders.id_product', '=', 'products.id_product')->orderBy('id_order', 'desc')->get();
$total_card = 0;
foreach ($orders as $order) {
if ($order->order_status != 'CANCELED') {
$total_card = $total_card + $order->quantity * $order->price;
}
}
$cards->total_card = $total_card;
return view('comandas.visualizar', compact('orders', 'cards'));
}
示例8: getOrderStatusIdByTransactionNumber
/**
* Get order status id by order id
*
* @param $id
* @return $statusId
*/
public function getOrderStatusIdByTransactionNumber($transaction_number)
{
return Order::select('status_id')->where('transaction_number', '=', $transaction_number)->first()->status_id;
}
示例9: getTickers
/**
* Get latest ticker data.
*/
public static function getTickers()
{
$pairs = self::generatePairs();
$tickers = [];
foreach ($pairs as $name => $pair) {
$base = $pair['base_id'];
$market = $pair['id'];
$tickers[$name] = ['high' => 0, 'low' => 0, 'avg' => 0, 'vol' => 0, 'vol_curr' => 0, 'buy' => 0, 'sell' => 0, 'updated' => time()];
$last_sell = Order::select('price')->where(function (\Illuminate\Database\Eloquent\Builder $query) use($base, $market) {
$query->where('wallet_id', $base)->where('want_wallet_id', $market);
})->where('type', 'sell')->orderBy('created_at', 'desc')->first();
if ($last_sell) {
$tickers[$name]['sell'] = (double) $last_sell->price;
}
$last_buy = Order::select('price')->where(function (\Illuminate\Database\Eloquent\Builder $query) use($base, $market) {
$query->where('wallet_id', $base)->where('want_wallet_id', $market);
})->where('type', 'buy')->orderBy('created_at', 'desc')->first();
if ($last_buy) {
$tickers[$name]['buy'] = (double) $last_buy->price;
}
$last_chart_prices = OrdersChart::where('wallet_id', $base)->where('want_wallet_id', $market)->where('interval', 86400)->orderBy('date', 'desc')->first();
if ($last_chart_prices) {
$tickers[$name]['high'] = (double) $last_chart_prices->high;
$tickers[$name]['low'] = (double) $last_chart_prices->low;
}
$last_chart_volume = OrdersChart::where('wallet_id', $base)->where('want_wallet_id', $market)->where('interval', 86400)->orderBy('date', 'desc')->first();
if ($last_chart_volume) {
$tickers[$name]['vol_curr'] = (double) $last_chart_volume->volume;
}
$base_volume = OrdersTransaction::selectRaw('
SUM(amount*price) AS volume
')->where(function (\Illuminate\Database\Eloquent\Builder $query) use($base, $market) {
$query->where('wallet_id', $base)->where('want_wallet_id', $market);
})->where('type', 'sell')->where('created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 24 HOUR)'))->first();
if ($base_volume) {
$tickers[$name]['vol'] = (double) $base_volume->volume;
}
}
return $tickers;
}
示例10: get_dashboard_data
public function get_dashboard_data(Request $request)
{
$base_id = $request->base_id;
$current_gen = Gen::getCurrentGen();
$gen_id = $request->gen_id;
if ($gen_id) {
$current_gen = Gen::find($gen_id);
}
$this->data['current_gen'] = $current_gen;
if ($base_id == null) {
$zero_paid_num = Register::where('gen_id', $current_gen->id)->where('status', '=', 1)->where('money', '=', 0)->count();
$total_money = Register::where('gen_id', $current_gen->id)->sum('money');
$num = Register::where('gen_id', $current_gen->id)->count();
$paid_number = Register::where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
$uncalled_number = Register::where('gen_id', $current_gen->id)->where('call_status', 0)->groupBy('user_id')->count();
$total_classes = $current_gen->studyclasses->count();
$remain_days = strtotime($current_gen->end_time) - time();
$registers_by_date = Register::select(DB::raw('count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
$money_by_date = Register::select(DB::raw('sum(money) as money'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
$registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
$orders_by_hour = Order::select(DB::raw('DATE(created_at) as date,count(1) as num'))->groupBy(DB::raw('DATE(created_at)'))->get();
$e = date('Y-m-d', time());
$s = date('Y-m-d', time() - 24 * 60 * 60 * 7 * 4);
$month_ago = createDateRangeArray(strtotime($s), strtotime($e));
$orders = [];
foreach ($orders_by_hour as $i) {
$orders[$i->date] = $i->num;
}
$return_orders = [];
foreach ($month_ago as $day) {
if (array_key_exists($day, $orders)) {
$return_orders[$day] = $orders[$day];
} else {
$return_orders[$day] = 0;
}
}
$registers_hour_array = array();
for ($i = 0; $i < 24; $i++) {
$registers_hour_array[$i] = 0;
}
foreach ($registers_by_hour as $regis) {
$registers_hour_array[$regis->hour] = $regis->num;
}
$this->data['money_by_date'] = json_encode($money_by_date);
$this->data['zero_paid_num'] = $zero_paid_num;
$this->data['classes'] = $current_gen->studyclasses;
$this->data['total_money'] = is_numeric($total_money) ? $total_money : 0;
$this->data['register_number'] = is_numeric($num) ? $num : 0;
$this->data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
$this->data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
$this->data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
$this->data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
$this->data['date_array'] = json_encode(createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time)));
$this->data['registers_by_date'] = json_encode($registers_by_date);
$this->data['registers_by_hour'] = json_encode($registers_hour_array);
$this->data['orders_by_hour'] = json_encode(array_values($return_orders));
$this->data['month_ago'] = json_encode($month_ago);
} else {
$base = Base::find($base_id);
$classes = $base->classes()->where('gen_id', $current_gen->id);
$registers = Register::where('gen_id', $current_gen->id)->where('gen_id', $current_gen->id)->whereIn('class_id', $classes->pluck('id'));
$zero_paid_num = Register::where('status', '=', 1)->where('money', '=', 0)->whereIn('class_id', $classes->pluck('id'))->count();
$total_money = $registers->sum('money');
$num = $registers->count();
$paid_number = $registers->where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
$uncalled_number = $registers->where('call_status', 0)->groupBy('user_id')->count();
$total_classes = $classes->count();
$remain_days = strtotime($current_gen->end_time) - time();
$classes_id = $classes->pluck("id");
$registers_by_date = Register::select(DB::raw('count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
$registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
$money_by_date = Register::select(DB::raw('sum(money) as money'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
$registers_hour_array = array();
for ($i = 0; $i < 24; $i++) {
$registers_hour_array[$i] = 0;
}
foreach ($registers_by_hour as $regis) {
$registers_hour_array[$regis->hour] = $regis->num;
}
$this->data['money_by_date'] = json_encode($money_by_date);
$this->data['zero_paid_num'] = $zero_paid_num;
$this->data['classes'] = $classes->get();
$this->data['total_money'] = is_numeric($total_money) ? $total_money : 0;
$this->data['register_number'] = is_numeric($num) ? $num : 0;
$this->data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
$this->data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
$this->data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
$this->data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
$this->data['date_array'] = json_encode(createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time)));
$this->data['registers_by_date'] = json_encode($registers_by_date);
$this->data['registers_by_hour'] = json_encode($registers_hour_array);
}
return view('components.dashboard_data', $this->data);
}
示例11: getNextOrderId
public function getNextOrderId()
{
$id = Order::select("order_id")->orderBy('order_id', 'desc')->first()->order_id + 1;
if ($id) {
return $id;
} else {
return 1;
}
}