本文整理汇总了PHP中app\Order::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::where方法的具体用法?PHP Order::where怎么用?PHP Order::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['accountname' => 'required|max:255', 'iban' => 'required|min:20|max:20', 'subject' => 'required|max:255', 'sum' => 'required', 'order_id' => 'required|integer|min:1']);
$values = $request->all();
$values = array_map('trim', $values);
//remove leading and trailing whitespaces on all values
$values['group'] = Auth::user()->group;
//try calculating the sum from string
try {
$calculator = new \NXP\MathExecutor();
$values['sum'] = $calculator->execute($values['sum']);
} catch (Exception $e) {
Log::Info('Input: "' . $values['sum'] . '" has failed to evaluate');
}
// Check whether the order exists and is actually owned by the given group
$order = Order::where('id', $values['order_id'])->where('group', $values['group'])->firstOrFail();
if ($validator->fails()) {
// Return JSON response with 422 HTTP status code
return $validator->errors()->all();
}
// Validation successful, store entity
$payment = new Payment($values);
$payment->save();
return $payment;
}
示例2: BrojUserPorudzbina
public function BrojUserPorudzbina()
{
$usersId = Auth::user()->id;
// $porudzbine =Order::get();
$userPosts = Order::where('user_id', $usersId)->count();
$iznos = Order::where('user_id', $usersId)->latest('created_at')->take(1)->first();
// user porudzbine evidencija
// $usersId2=Auth::user()->id;
//
//
// $porudzbine2 = DB::table('order');
//
// $osnovnaPorudzbina= $porudzbine2->where('user_id', $usersId2)->latest('created_at')->take(1)->pluck('created_at');
////
////
////
// $time = date('H:i:s', strtotime($osnovnaPorudzbina));
////
//// kreirano vreme
// $date=Carbon::createFromFormat('H:i:s', $time);
// $vreme= $date->addMinutes(30);
//// $vreme=date('H:i:s', strtotime($vreme));
//
//// vreme posle 30 minuta
//
// $trenutno= Carbon::now();
// print gmdate("H:i:s", $trenutno->diffInSeconds($vreme));
return view('articles.glavni', compact('userPosts', 'iznos'));
}
示例3: update
public function update(Request $request, $id)
{
//
$data = $request->all();
Order::where('id', $id)->update(array('status' => $data['status'], 'shipped_date' => $data['shipped_date']));
return Redirect::back();
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$menuOptions = [0 => ["data-letters" => "", "id" => "home", "text" => "Home", "href" => "/"]];
if (Auth::check()) {
$user = Auth::user();
$verifyAdmin = Admin::find($user->id);
if (isset($verifyAdmin->id)) {
$users = User::all();
$fabrics = Fabric::all();
$data = array("latestOrders" => Order::getOrders(0), "latestUsers" => User::where("confirmed", "=", "0")->orderBy("created_at", "")->take(5)->get(), "user" => $user, "users" => $users, "fabrics" => $fabrics, "orders" => Order::getOrders(0), "confirmed-users" => User::where("confirmed", "=", "1")->orderBy("created_at", "")->take(5)->get(), "admin" => true);
/*Session::put('paginate', [
"confirmed-users" => 5,
"not-confirmed-users" => 5,
"not-confirmed-orders" => 5,
"confirmed-orders" => 5
]);*/
return view("panel.admin-panel")->with("data", $data)->with("user", $user);
} else {
$stats = ["orders" => Order::where("user_id", "=", $user->id)->count(), "unconfirmed" => Order::where("user_id", "=", $user->id)->where("status", "=", "not-confirmed")->count(), "confirmed" => Order::where("user_id", "=", $user->id)->where("status", "=", "confirmed")->count(), "latest" => Order::where("user_id", "=", $user->id)->max("created_at")];
//dd(Order::getOrdersUser($user->id));
$data = array("orders" => Order::getOrdersUser($user->id, 0), "stats" => $stats, "fabrics" => Fabric::all(), "admin" => false);
/*Session::put('paginate', [
"confirmed-orders" => 5,
"not-confirmed-orders" => 5,
]);*/
return view("panel.normal-panel")->with("user", $user)->with("data", $data);
}
} else {
return redirect("/")->with("menuOptions", $menuOptions);
}
}
示例5: getIndex
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getIndex(Request $request)
{
// Get all the orders created by the current logged in users
// Sort in descending order by id
$orders = \App\Order::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
return view('orders.index')->with('orders', $orders);
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$days_to_wait = Config::get('store.days_to_remind');
//\DB::enableQueryLog();
$this->info("Checks If there are orders to be rated ({$days_to_wait} Days Old)");
//Checks all closed orders that has not been rated nor mail has been sent and where updated 5 days ago
//and the mails has not been sent yet
$orders = Order::where('rate', null)->where('status', 'closed')->where('rate_mail_sent', false)->where('updated_at', '<', Carbon::now()->subDays($days_to_wait))->get();
//$this->info(print_r(\DB::getQueryLog()));
$this->info("Orders That need mail: " . $orders->count());
foreach ($orders as $order) {
$this->info("Order: " . $order->id . ' Needs to be rated, and mail has not been sent');
$buyer = User::find($order->user_id);
if ($buyer) {
$email = $buyer->email;
$mail_subject = trans('email.cron_emails.remind_rate_order_subject');
$data = ['email_message' => $mail_subject, 'email' => $email, 'subject' => $mail_subject, 'order_id' => $order->id];
Mail::queue('emails.cron.rate_order', $data, function ($message) use($data) {
$message->to($data['email'])->subject($data['subject']);
});
$order->rate_mail_sent = true;
$order->save();
}
}
}
示例7: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$studentid = Auth::user()->studentid;
$orders = Order::where('userid', '=', $studentid)->get();
$applications = Application::where('studentid', '=', $studentid)->get();
return view('infohome', ['orders' => $orders, 'applications' => $applications]);
}
示例8: orders
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function orders()
{
$begin = new DateTime(\Carbon\Carbon::now()->subDays(7));
$end = new DateTime(\Carbon\Carbon::now());
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
// $orderCount = [];
// foreach ($period as $p ){
// $dt = $p->format( "Y-m-d" );
// $oc = Order::where('dateOrdered', $dt)->where('status_id', '>', 1)->count();
// $orderCount[] = $oc;
// };
$orderCount = [];
for ($i = 7; $i >= 0; $i--) {
$oc = Order::where('dateOrdered', \Carbon\Carbon::now()->subDays($i)->format('Y-m-d'))->count();
$orderCount[] = $oc;
}
$sumTransactions = [];
for ($i = 7; $i >= 0; $i--) {
$sum = Order::where('dateOrdered', \Carbon\Carbon::now()->subDays($i)->format('Y-m-d'))->sum('transaction_total');
$sumTransactions[] = $sum;
}
$dates = [];
foreach ($period as $p) {
$dt = $p->format("Y-m-d");
$dates[] = $dt;
}
return view('metrics.orders', ['dates' => $dates, 'orderCount' => $orderCount, 'sumTransactions' => $sumTransactions]);
}
示例9: deleteOrder
public function deleteOrder(Request $request)
{
$order_id = \StringHelper::filterString($request->input('order_id'));
$deletedRows = Order::where('id', $order_id)->delete();
$catRow = OrderDetail::where('order_id', $order_id)->delete();
return Redirect::back()->with('message', 'Success');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['order_id' => 'required|integer|min:1', 'vorname' => 'required|max:255', 'nachname' => 'required|max:255', 'strasse' => 'required|max:255', 'PLZ' => 'required|min:4|max:5', 'stadt' => 'required|max:255']);
if ($validator->fails()) {
// Return JSON response with 422 HTTP status code
return $validator->errors()->all();
}
$values = $request->all();
$values = array_map('trim', $values);
//remove leading and trailing whitespaces on all values
$values['group'] = Auth::user()->group;
// Check whether the order exists and is actually owned by the given group
$order = Order::where('id', $values['order_id'])->where('group', $values['group'])->firstOrFail();
unset($values['order_id']);
// Validation successfull, let's check if we already have a customer with the same namespace
$customer = Customer::where('vorname', $values['vorname'])->where('nachname', $values['nachname'])->where('strasse', $values['strasse'])->where('PLZ', $values['PLZ'])->where('stadt', $values['stadt'])->where('group', $values['group'])->first();
Log::Info(print_r($customer, true));
// if this is a new customer, we create it first
if (is_null($customer)) {
//|| $customer->isEmpty()
$customer = new Customer($values);
$customer->save();
}
$existing_associations = $order->customer()->lists('id');
// check if the relation between order and customer is already established
if (!in_array($customer->id, array_values($existing_associations->toArray()))) {
// link the customer to the order
$order->customer()->attach($customer->id);
}
// Return customer object
return $customer;
}
示例11: 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);
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$orders = Order::where('status', '=', '0')->get();
$pageData = self::orderPageData('pending', 1, 0, 1, 1);
$pageData['table'] = $orders;
return view('panel.orders', $pageData);
}
示例13: purchasedCards
public function purchasedCards(Request $request)
{
$new_purchase = $request->session()->get('card_purchased', false);
$cards = Order::where('user_id', $this->user->id)->get();
$cart_items = $this->cart->totalItems();
return view('user.purchased_cards')->with(compact('cards', 'cart_items', 'new_purchase'));
}
示例14: 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');
}
}
示例15: index
/**
* Display a listing of client orders.
*
* @return Response
*/
public function index()
{
$user = \Auth::user();
$client = $user->client;
$allOrders = Order::where('client_id', '=', $client->id)->orderBy('created_at', 'DESC')->get();
return view('clients.orders')->with('allOrders', $allOrders);
}