本文整理汇总了PHP中app\models\Order::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::find方法的具体用法?PHP Order::find怎么用?PHP Order::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Order
的用法示例。
在下文中一共展示了Order::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeOrder
public function makeOrder(DeliveryRequest $request)
{
$this->validate($request);
$orders = new Order();
$orders->address = $request->input('address');
$orders->contact = $request->input('contact');
$orders->phone = $request->input('phone');
$orders->email = $request->input('email');
$orders->sendwhen = null;
$orders->created = date('Y-m-d H:i:s');
$orders->additional = $request->input('additional');
$orders->status = Order::STATUS['NEW'];
$orders->totalprice = \App\Components\Cart::getInstance()->getTotalPrice();
$orders->save();
$request->except('_token');
$inserted = Order::find($orders->id);
$inserted->products()->saveMany(Orderproducts::reFormatCartList());
Cart::getInstance()->clearAll();
return redirect('categories/all');
}
示例2: createPayment
public function createPayment(Request $request)
{
Auth::user();
$order_id = session('order_id');
$order = Order::find($order_id);
if ($order) {
$user = $order->id;
$sum = $order->sum;
$mrh_login = env('ROBOKASSA_LOGIN');
$mrh_pass1 = env('ROBOKASSA_PASSWORD');
$invoice_id = mt_rand();
$inv_desc = 'Пополнение баланса';
$crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
if ($sum != 0) {
try {
DB::beginTransaction();
$payment = new Payment();
$payment->uid = $invoice_id;
$payment->user_id = $user;
$payment->balance = $sum;
$payment->description = $inv_desc;
$payment->operation = '+';
$payment->save();
DB::commit();
} catch (\PDOException $e) {
print $e->getMessage();
DB::connection()->getPdo()->rollBack();
}
}
echo 'ok';
return 1;
header("Location: https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}");
}
}
示例3: unFinishOrder
/**
* Put an order from finished to unfinished
*
* @param $id
* @return mixed
*/
public function unFinishOrder($id)
{
$order = Order::find($id);
$order->finished = null;
$order->save();
return $order;
}
示例4: create_payment
private function create_payment($order_id)
{
$order = Order::find($order_id);
if ($order) {
$user = $order->user_id;
$sum = $order->sum;
$mrh_login = env('ROBOKASSA_LOGIN');
$mrh_pass1 = env('ROBOKASSA_PASSWORD');
$invoice_id = mt_rand();
$inv_desc = 'Пополнение баланса';
$crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
if ($sum != 0) {
try {
DB::beginTransaction();
$payment = new Payment();
$payment->uid = $invoice_id;
$payment->order_id = $order_id;
$payment->user_id = $user;
$payment->sum = $sum;
$payment->description = $inv_desc;
$payment->operation = '+';
$payment->payment_type = $order->payment_type;
$payment->save();
DB::commit();
} catch (\PDOException $e) {
print $e->getMessage();
DB::connection()->getPdo()->rollBack();
}
}
$redirect_url = "https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}&IsTest=1";
return $redirect_url;
}
return Redirect::to('/')->with('message', 'Ошибка');
}
示例5: testStore
public function testStore()
{
$this->post(route('api.admin.order.product.index', [$this->order]), json_encode(['product_id' => 1, 'sku' => 'iphone616-gold', 'quantity' => 2]));
$order = Order::find($this->order->id);
$this->assertNotEquals($this->order->subtotal_product, $order->subtotal_product, $this->response->getContent());
$this->assertNotEquals($this->order->subtotal_logistics, $order->subtotal_logistics, $this->response->getContent());
$this->assertResponseStatus(201);
}
示例6: show
/**
* order details.
*
* @return Response
*/
public function show($id)
{
$order = Order::find($id);
if (!$order) {
\App::abort(404);
}
return view('themes/kudos/orders/show', ['order' => $order]);
}
示例7: index
public function index($cat = null, $id = null)
{
if (!$cat) {
$resource = \App\Models\Kingdom::select('kingdom.kingdom_name as name', 'kingdom.kingdom_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/kingdom/', kingdom.kingdom_id) AS url"));
$resourceData = $resource->join('phylum', 'kingdom.kingdom_id', '=', 'phylum.kingdom_id', 'left outer')->join('class', 'phylum.phylum_id', '=', 'class.phylum_id', 'left outer')->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('kingdom.kingdom_id', 'kingdom.kingdom_name')->paginate(20);
} else {
switch ($cat) {
case 'kingdom':
$resource = \App\Models\Kingdom::find($id);
$resourceData = $resource->phylums()->select('phylum.phylum_name as name', 'phylum.phylum_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/phylum/', phylum.phylum_id) AS url"))->join('class', 'phylum.phylum_id', '=', 'class.phylum_id', 'left outer')->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('phylum.phylum_id', 'phylum.phylum_name')->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->kingdom_name));
break;
case 'phylum':
$resource = \App\Models\Phylum::find($id);
$resourceData = $resource->classes()->select('class.class_name as name', 'class.class_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/class/', class.class_id) AS url"))->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('class.class_id', 'class.class_name')->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->phylum_name));
array_unshift($this->breadcrumbs, array('name' => $resource->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->kingdom->kingdom_id));
break;
case 'class':
$resource = \App\Models\Classes::find($id);
$resourceData = $resource->orders()->select('order.order_name as name', 'order.order_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/order/', order.order_id) AS url"))->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('order.order_id', 'order.order_name')->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->class_name));
array_unshift($this->breadcrumbs, array('name' => $resource->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->phylum->phylum_id));
array_unshift($this->breadcrumbs, array('name' => $resource->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->phylum->kingdom->kingdom_id));
break;
case 'order':
$resource = \App\Models\Order::find($id);
$resourceData = $resource->families()->select('family.family_name as name', 'family.family_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/family/', family.family_id) AS url"))->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('family.family_id', 'family.family_name')->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->order_name));
array_unshift($this->breadcrumbs, array('name' => $resource->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->classes->class_id));
array_unshift($this->breadcrumbs, array('name' => $resource->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->classes->phylum->phylum_id));
array_unshift($this->breadcrumbs, array('name' => $resource->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->classes->phylum->kingdom->kingdom_id));
break;
case 'family':
$resource = \App\Models\Family::find($id);
$resourceData = $resource->genus()->select('genus.genus_name as name', 'genus.genus_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/genus/', genus.genus_id) AS url"))->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->groupBy('genus.genus_id', 'genus.genus_name')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->family_name));
array_unshift($this->breadcrumbs, array('name' => $resource->order->order_name, 'url' => '/dnabarcode/order/' . $resource->order->order_id));
array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->order->classes->class_id));
array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->order->classes->phylum->phylum_id));
array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->order->classes->phylum->kingdom->kingdom_id));
break;
case 'genus':
$resource = \App\Models\Genus::find($id);
$resourceData = $resource->species()->select('species.species_name as name', DB::raw("CONCAT('/viewbarcode?id=' , barcode_id) AS url"))->join('barcode', 'barcode.species', '=', 'species.species_id')->where('barcode.status', 1)->paginate(20);
array_unshift($this->breadcrumbs, array('name' => $resource->genus_name));
array_unshift($this->breadcrumbs, array('name' => $resource->family->family_name, 'url' => '/dnabarcode/family/' . $resource->family->order_id));
array_unshift($this->breadcrumbs, array('name' => $resource->family->order->order_name, 'url' => '/dnabarcode/order/' . $resource->family->order->order_id));
array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->family->order->classes->class_id));
array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->family->order->classes->phylum->phylum_id));
array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->family->order->classes->phylum->kingdom->kingdom_id));
break;
}
}
array_unshift($this->breadcrumbs, array('name' => 'DNA Barcode', 'url' => '/dnabarcode'));
$viewData = array('resource' => $resourceData, 'breadcrumbs' => $this->breadcrumbs, 'cat' => $cat);
return view('list')->with($viewData);
}
示例8: detail
public function detail($id)
{
$customer = \Helper::getCustomer();
$order = Order::find($id);
if (!$order || $order->customer_id != $customer->id) {
abort(404);
}
return view('shop.order-details')->with(['json' => $order->queryForDetailPage()]);
}
示例9: getOrders
public function getOrders($id = null)
{
if ($id) {
//details
return view('order.details', ['products' => OrderProduct::where('order_id', $id)->get(), 'order' => Order::find($id)]);
} else {
return view('order.index', ['orders' => Order::where('user_id', Auth::id())->get()]);
}
}
示例10: destroy
/**
* Delete an order.
*
* @param string $id
*
* @return Redirect
*/
public function destroy(Request $request, string $id)
{
// delete
$order = Order::find($id);
$order->delete();
// redirect
$request->session()->flash('success', trans('orders.order') . ' ' . trans('crud.deleted'));
return redirect('admin/orders');
}
示例11: actionOrders
public function actionOrders()
{
if (!is_null($user = $this->getLoggedUser())) {
$data = new ActiveDataProvider(['query' => Order::find()->where(['user_id' => $user->id])->orderBy(['created' => SORT_DESC]), 'pagination' => ['pageSize' => 5]]);
return $this->render('orders', ['data' => $data]);
} else {
return $this->redirect(['site/register']);
}
}
示例12: actionAll
public function actionAll()
{
if (Yii::$app->user->isGuest) {
return $this->goHome();
}
$query = Order::find()->where(['id_owner' => Yii::$app->user->id]);
$pagination = new Pagination(['defaultPageSize' => 15, 'totalCount' => $query->count()]);
$orders = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('allorder', ['orders' => $orders, 'pagination' => $pagination]);
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$order = Order::find($id);
$order->express_code = $request->express_code;
if ($order->status == 1) {
$order->status = 2;
}
$order->save();
return back()->with('info', '订单号修改成功~');
}
示例14: actionIndex
/**
* Lists all Order models.
* @return mixed
*/
public function actionIndex()
{
if (User::isUserAdmin(Yii::$app->user->identity->username)) {
$query = Order::find()->joinWith(['orderLocationName']);
} else {
$query = Order::find()->joinWith(['orderLocationName'])->where(['order_user_id' => Yii::$app->user->id]);
}
$dataProvider = new ActiveDataProvider(['query' => $query]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}
示例15: actionIndex
public function actionIndex()
{
// last orders
$data['orders'] = Order::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
// last registered users
$data['users'] = User::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
// top sellers
$sql = "select product_id, sum(quantity) as cant from order_products left join simplestore.order on order.id=order_products.order_id where order.status=:approved group by product_id order by cant desc limit :limit";
$data['products'] = Yii::$app->db->createCommand($sql, [':approved' => Order::STATUS_APPROVED, ':limit' => 10])->queryAll();
return $this->render('index', $data);
}