public function actionPayment() { if (\Yii::$app->session->has('customer')) { $modelCustomer = new Customer(); $infoCustomer = $modelCustomer->getInformation($_SESSION['customer']); $modelOrder = new Order(); $modelOrderDetail = new OrderDetail(); $modelProduct = new Product(); $ids = array(); foreach ($_SESSION['cart_items'] as $id => $quantity) { array_push($ids, $id); } $products = $modelProduct->getWithIDs($ids); if (\Yii::$app->request->post()) { $modelOrder->load(\Yii::$app->request->post()); $modelOrder->save(); $orderId = $modelOrder->id; foreach ($_SESSION['cart_items'] as $id => $quantity) { $unitPrice = $modelProduct->getPrice($id) * $quantity; \Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute(); } \Yii::$app->session->remove('cart_items'); return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']); } else { return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]); } } else { $this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']); } }
function generate() { /* INV-ddmmyyyXXXXX (INV-0206201500356) */ // $lastInvoice = "INV-270720150001"; $orders = new Order(); $lastOrder = $orders->orderBy('created_at', 'desc')->first(); if ($lastOrder) { $lastInvoice = $lastOrder->invoice_no; } # date configuration $date = Date('d'); $month = Date('m'); $year = Date('Y'); $newInvoice = ""; if (!$lastOrder || !$lastInvoice) { $newInvoice = "INV-" . $date . $month . $year . "0001"; } else { #get the month of the lastInvoice $last_inv_month = substr($lastInvoice, 6, 2); if (!$last_inv_month == $month) { $increment = "0001"; } else { #get last four digit of last invoice number $zeroDigits = ""; $invoice_length = strlen($lastInvoice); $last_increment = intval(substr($lastInvoice, $lastInvoice - 4, 4)); for ($c = 0; $c < 4 - $last_increment; $c++) { $zeroDigits = $zeroDigits . "0"; } $new_increment = strval($last_increment + 1); $newInvoice = "INV-" . $date . $month . $year . $zeroDigits . $new_increment; } } return $newInvoice; }
public function actionOrder() { $order = new Order(); $products = $this->_cart->getPositions(); $total = $this->_cart->getCost(); if ($order->load(\Yii::$app->request->post()) && $order->validate()) { $order->user_id = 1; $order->cart_id = "text"; if ($order->save(false)) { foreach ($products as $product) { $orderItem = new OrderItem(); $orderItem->order_id = $order->id; $orderItem->product_id = $product->id; $orderItem->price = $product->getPrice(); $orderItem->quantity = $product->getQuantity(); if (!$orderItem->save(false)) { \Yii::$app->session->addFlash('error', 'Cannot place your order. Please contact us.'); return $this->redirect('site/index'); } } } $this->_cart->removeAll(); \Yii::$app->session->addFlash('success', 'Thanks for your order. We\'ll contact you soon.'); //$order->sendEmail(); return $this->redirect('site/index'); } return $this->render('order', ['order' => $order, 'products' => $products, 'total' => $total]); }
private function create_cart() { $order = new Order(); $order->user_id = $this->id; $order->save(); $this->order_id = $order->id; $this->save(); }
public function proceedToCheckout($total) { $order = new Order(); $userId = Yii::$app->user->identity->id; $order->user_id = $userId; $order->address = $this->address; $order->phone_number = $this->phoneNumber; $order->total = $total; return $order->save(false) && !$this->hasErrors() ? $order : null; }
public function feedback(Request $request) { $text = view('email.feedback', $request->all())->render(); $email = Config::get('mail.from')['address']; $order = new Order(); $order->save(); $number = $order->id; $result = mail($email, "[kolizej.ru] обращение №{$number}", $text, "Content-type: text/html; charset=utf-8\r\n"); return ['success' => $result ? true : false, 'number' => $number]; }
public function actionIndex() { //todo redis? $user = Yii::$app->session->get('user'); if (empty($user)) { $this->goHome(); } $user = User::findOne($user->id); if ($user->account < Yii::$app->params['auctionDeposit']) { $order = Order::find()->where(['type' => Order::TYPE_AUCTION, 'user_id' => $user->id, 'status' => Order::STATUS_CREATED])->one(); if (empty($order)) { $order = new Order(); $order->user_id = $user->id; $order->serial_no = Util::composeOrderNumber(Order::TYPE_AUCTION); $order->money = Yii::$app->params['auctionDeposit']; $auction = Auction::find()->where('end_time > NOW()')->orderBy('start_time, end_time')->limit(1)->one(); $order->auction_id = $auction->id; $order->status = Order::STATUS_CREATED; $order->type = Order::TYPE_AUCTION; $order->save(); } $this->redirect('/pay/index?order_id=' . $order->serial_no); } $auctions = Auction::find()->where('end_time > NOW()')->orderBy('start_time, type')->limit(3)->all(); $auctionIds = []; foreach ($auctions as $auction) { array_push($auctionIds, $auction->id); } $topOffers = $this->getTopOfferHash($auctionIds); $myOffers = $this->getMyTopOfferHash($user->id, $auctionIds); foreach ($topOffers as $tmpId => $tmpOffer) { if (!array_key_exists($tmpId, $myOffers)) { $myTmpOffer = []; $myTmpOffer['auction_id'] = $tmpId; $myTmpOffer['top'] = 0; $myOffers[$tmpId] = $myTmpOffer; } list($myOffers[$tmpId]['rank'], $myOffers[$tmpId]['class'], $myOffers[$tmpId]['message']) = $this->composeRankInfo($tmpId, $myOffers[$tmpId]['top']); } $isInAuction = $this->isInAuction(); $hasNextAuction = $this->hasNextAuction(); $startTime = isset($auctions[0]) ? $auctions[0]->start_time : ''; $endTime = isset($auctions[0]) ? $auctions[0]->end_time : ''; $countDownTime = str_replace(' ', 'T', $isInAuction ? $endTime : $startTime); $priceStep = Yii::$app->params['auctionStep']; $lang = Util::getLanguage(); $view = $lang == 'en' ? 'auction' : 'auction-cn'; Util::setLanguage($lang); return $this->render($view, compact('auctions', 'topOffers', 'myOffers', 'startTime', 'endTime', 'isInAuction', 'hasNextAuction', 'countDownTime', 'priceStep')); }
/** * 提交支付表单 * * @return Response */ public function store(Request $request) { //验证input信息 $this->validate($request, ['gateway' => 'required']); //创建订单... $orderSn = Order::createOrderSn(); $out_trade_no = $orderSn; //保存订单 //TODO //订单数据,暂时使用测试数据 $data = ['out_trade_no' => $out_trade_no, 'subject' => $out_trade_no . '号订单产品', 'total_fee' => '0.1', 'quantity' => 1, 'defaultBank' => 'CCB']; //保证金额正确性, 订单号,主题,支付金额由订单决定 $data = $data + Input::all(); //创建payway $gateway = Input::get('gateway'); Omnipay::setGateway($gateway); //数据对接-按配置参数重组数组 //如果符合则加入进新数组 $gateway = Omnipay::getGateway(); $purchaseParamKeys = Config::get('laravel-omnipay.gateways')[$gateway]['purchaseParamKeys']; $parameters = createNewKeyArray($data, $purchaseParamKeys); //获取request $resquest = Omnipay::purchase($parameters); //获取respond并跳转到第三方支付平台 $response = $resquest->send(); $response->redirect(); }
public function run() { DB::table('orders')->delete(); Order::create(array('id' => '1', 'user_id' => '1', 'total' => '4000', 'comment' => 'Позвоните мне.', 'delivery_price' => '1200', 'weight' => '40', 'distance' => '168', 'volume' => '50')); Order::create(array('id' => '2', 'user_id' => '1', 'total' => '7200', 'comment' => 'Есть в наличие?', 'delivery_price' => '1200', 'weight' => '80', 'distance' => '568', 'volume' => '50')); Order::create(array('id' => '3', 'user_id' => '1', 'total' => '1000', 'comment' => 'Когда отправите?', 'delivery_price' => '1200', 'distance' => '269', 'weight' => '50', 'volume' => '50')); }
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', 'Ошибка'); }
/** * Execute the command. * // * @return void */ public function handle() { $documents = Config::get('documents'); $whereAreClientDocuments = $documents['documents_folder']; //client_{id} if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id)) { Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id); } //paymentDocs if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType))) { Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType)); } $clientFolder = $whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . Order::getDocTypeName($this->docType); //(torg12/schetfactura)_{orderID}_{depoName}_date_{currentDate} $fileNameTemplate = $this->documentFor == Order::DOCUMENT_FOR_SERVICE ? $documents['client_service_document_template'] : $documents['client_document_template']; $fileNameTemplate = Utils::mb_str_replace('{docType}', Order::getDocTypeName($this->docType), $fileNameTemplate); $fileNameTemplate = Utils::mb_str_replace('{orderID}', $this->order->id, $fileNameTemplate); if ($this->documentFor == Order::DOCUMENT_FOR_SPARE_PART) { $depoName = $this->order->products_in_order[0]->stantion_name; $depoName = Utils::mb_str_replace(' ', '', $depoName); $depoName = Utils::translit($depoName); $fileNameTemplate = Utils::mb_str_replace('{depoName}', $depoName, $fileNameTemplate); } $fileNameTemplate = Utils::mb_str_replace('{currentDate}', time(), $fileNameTemplate); $extension = $this->file->getClientOriginalExtension(); try { Storage::disk('local')->put($clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate . '.' . $extension, File::get($this->file)); } catch (Exception $e) { Log::error('Ошибка загрузки файла ' . $fileNameTemplate . ' message - ' . $e->getMessage()); return false; } return storage_path() . DIRECTORY_SEPARATOR . 'app' . $clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate . '.' . $extension; }
public function notify(Request $request) { \Log::debug('payment_notify', ['request' => $request]); $input = XML::parse($request->getContent()); if ($input['return_code'] == 'SUCCESS') { $order = Order::where('wx_out_trade_no', $input['out_trade_no'])->firstOrFail(); $address_id = $order->address_id; # 当前订单收货地址id if ($order->isPaid()) { return 'FAIL'; } $order->update(['wx_transaction_id' => $input['transaction_id'], 'cash_payment' => floatval($input['total_fee']) / 100.0]); $order->paid(); /* 发送消息提醒 */ $default_address = Address::where(['id' => $address_id])->first(); $phone = $default_address->phone; $msg = '尊敬的顾客您好!您的订单已经收到,易康商城将尽快为您安排发货,如有任何问题可以拨打客服电话400-1199-802进行咨询,感谢您的惠顾!'; \MessageSender::sendMessage($phone, $msg); // if ($phone = env('ORDER_ADMIN_PHONE')) { // \Log::error($phone); // \MessageSender::sendMessage($phone, $order->toOrderMessageString()); // } $result = \Wechat::paymentNotify(); return $result; } return 'FAIL'; }
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}"); } }
public function getOrders() { //with用法,先不用all查询 $orders = $this->hasMany(Order::className(), array('cid' => 'id'))->asArray(); //->all(); return $orders; }
/** * 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; }
public function request_post() { $post = Input::all(); $rules = ['name' => 'required', 'phone' => 'required', 'aid' => 'required']; $validator = Validator::make($post, $rules); if ($validator->fails()) { return redirect()->back()->with('error', $validator->errors()->all())->withInput(); } $order = new Order(); $order->name = $post['name']; $order->phone = $post['phone']; $order->aid = $post['aid']; $order->type = $post['type']; $order->save(); return redirect()->back()->with('success', trans('message.message_success_send')); }
public function getSales() { $from = Input::get('from'); $to = Input::get('to'); $all_orders = Order::where(function ($q) use($from, $to) { if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $paid_orders = Order::where(function ($q) use($from, $to) { $q->where('state', '1'); if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $total_summ_paid_orders = 0; foreach ($paid_orders as $order) { $total_summ_paid_orders += $order->sum; } $period = ['from' => $from, 'to' => $to, 'text' => $this->period_text($from, $to)]; return view('admin.stat.sales', ['paid_orders' => $paid_orders, 'orders' => $all_orders, 'total_summ_paid_orders' => number_format($total_summ_paid_orders, 2, ',', ' '), 'period' => $period]); }
/** * Edit a customer. * * @param string $id * * @return Response */ public function edit($id) { $customer = User::find($id); $addresses = Address::where('customer_id', '=', $customer->id)->get(); $orders = Order::where('customer_id', '=', $customer->id)->get(); return view('admin/customers/edit', ['customer' => $customer, 'addresses' => $addresses, 'orders' => $orders]); }
public function getTodayVotessCountAttribute() { $order = Order::today(); if ($order == null) { return '0'; } return Vote::where('order_id', '=', $order->id)->where('place_id', '=', $this->id)->count(); }
protected function storeNewOrder(array $data) { $id = Auth::user()->id_user; $data['advPay'] = isset($data['advPay']) ? 1 : 0; Log::info('User: '******' submitted new order, destination: ' . $data['orderDestination'] . ', departure: ' . $data['dateFrom'] . ', arrival: ' . $data['dateFrom'] . 'advPay: ' . $data['advPay']); // LOG $order = Order::create(['destination' => $data['orderDestination'], 'date_departure' => $data['dateFrom'], 'date_arrival' => $data['dateTo'], 'adv_pay' => $data['advPay'], 'user_id_user' => $id]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $user = User::find($id); $orders = Order::with('address')->where('user_id', $id)->orderBy('created_at', 'desc')->paginate(config('wyshop.page_size')); // return $orders; $order_status = config('wyshop.order_status'); return view('admin.order.index', ['orders' => $orders, 'order_status' => $order_status]); }
protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * 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]); }
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); }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $order = $event->order; if (is_null(Order::where('customer_id', $customer->id)->where('order_status_id', '>=', 2)->where('id', '!=', $order->id)->first())) { dispatch(new FirstOrderFeedback($customer)); } }
public function createOrder(Request $request) { // get the basket $basket = $request->session()->get('basket'); // save order $order = new Order(); $order->shop_id = $request->session()->get('shop'); $order->customer_id = Auth::user()->id; $order->shipping_id = $request->shipping_id; $order->billing_id = $request->billing_id; $order->total = $basket['subtotal']; $basket['shipping'] = Address::find($request->shipping_id)->toArray(); $basket['billing'] = Address::find($request->billing_id)->toArray(); $order->basket = $basket; $order->save(); return $order; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $firmName = $user->firm->organisation_name; $countOfOrders = Order::where('user_id', Auth::user()->id)->count(); $countOfDocuments = Document::where('user_id', Auth::user()->id)->count(); return view('cabinet.index', ['p' => 'cabinet', 'userId' => $user->id, 'firmName' => $firmName, 'countOfOrders' => $countOfOrders, 'countOfDocuments' => $countOfDocuments]); }
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); }
/** * 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'); }
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()]); } }