コード例 #1
0
 public function get($zip = null, $ken_furi = null, $city_furi = null, $town_furi = null)
 {
     $addr = new Models\Address();
     /** @var \Illuminate\Database\Query\Builder $q */
     $q = $addr->newQuery();
     $decoded_zip = Models\Address::processZip($zip);
     $q->orWhere('zip', '=', $decoded_zip);
     foreach (['ken_furi', 'city_furi', 'town_furi'] as $col) {
         Models\Address::filterQueryFuri(${$col}, $q, $col);
     }
     /** @var \Illuminate\Database\Eloquent\Collection|static[] $results */
     $columns = ['ken_id', 'zip', 'ken_name', 'ken_furi', 'city_name', 'city_furi', 'town_name', 'town_furi', 'kyoto_street', 'block_name', 'office_name', 'office_address'];
     $results = $q->take(10)->get($columns);
     // NULLのフィールドを省略
     $resultsArray = array_map(function ($result) use($columns) {
         foreach ($columns as $col) {
             if (array_key_exists($col, $result) && ($result[$col] === 'NULL' || trim(mb_convert_kana($result[$col], 's')) === '')) {
                 unset($result[$col]);
             }
         }
         return $result;
     }, $results->toArray());
     $date = date('Y/m/d H:i:s');
     return $results->count() > 0 ? response()->json(['error' => 'success', 'date' => $date, 'count' => $results->count(), 'results' => $resultsArray]) : response()->json(['error' => 'error', 'date' => $date, 'count' => 0]);
 }
コード例 #2
0
ファイル: PersonController.php プロジェクト: slavam/placement
 /**
  * Creates a new Person model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Person();
     $address = new Address();
     if ($model->load(Yii::$app->request->post()) && $address->load(Yii::$app->request->post()) && $model->save()) {
         //            if (Yii::$app->request->isAjax)
         //                return $this->renderAjax('view', [
         //                    'model' => $model,
         //                ]);
         Yii::$app->getSession()->addFlash('success', "Запись \"{$model->fullName}\" успешно добавлена.");
         return $this->redirect(Url::previous() != Yii::$app->homeUrl ? Url::previous() : ['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->referrer != Yii::$app->request->absoluteUrl) {
             Url::remember(Yii::$app->request->referrer ? Yii::$app->request->referrer : null);
         }
         //            if (Yii::$app->request->isAjax)
         //                return $this->renderAjax('_form', [
         //                    'model' => $model,
         //                    'address' => $address,
         //                ]);
         if (!Yii::$app->request->isPost) {
             $model->load(Yii::$app->request->get());
         }
         return $this->render('create', ['model' => $model, 'address' => $address]);
     }
 }
コード例 #3
0
 public function testShouldUpdateCurrentLocation()
 {
     $currentLocation = null;
     $latitude = -23.48033;
     $longitude = -46.63459;
     $city = new City();
     $city->setName("São Paulo");
     $city->setState("SP");
     $address = new Address();
     $address->setCity($city);
     $address->setStreet("Rua Funchal");
     $address->setDistrict("Vila Olímpia");
     $api = $this->getMock("ApontadorApi", array("revgeocode"));
     $api->expects($this->once())->method("revgeocode")->with($latitude, $longitude)->will($this->returnValue($address));
     $locationController = new LocationController();
     $locationController->setApi($api);
     $locationController->disableSession();
     $locationController->update($latitude, $longitude);
     $current = $locationController->current();
     $currentLocation = new Location($current['location']);
     $this->assertNotNull($currentLocation);
     $this->assertSame("SP", $currentLocation->getAddress()->getCity()->getState());
     $this->assertSame("São Paulo", $currentLocation->getAddress()->getCity()->getName());
     $this->assertSame("Vila Olímpia", $currentLocation->getAddress()->getDistrict());
     $this->assertSame("Rua Funchal", $currentLocation->getAddress()->getStreet());
     $this->assertSame($latitude, $currentLocation->getPoint()->getLat());
     $this->assertSame($longitude, $currentLocation->getPoint()->getLng());
 }
コード例 #4
0
ファイル: Address.php プロジェクト: khakanali/OpenMAll
 public function store(Request $request)
 {
     $address_data = $this->collectAddressFormData($request);
     $address = new Address();
     $address_model = $address->create($address_data);
     return $address_model;
 }
コード例 #5
0
 /**
  * @covers \App\Services\Factories\AddressFactory::modify()
  */
 public function testModify()
 {
     $address = new Address(array('street_1' => 'Foo_street_1', 'street_2' => 'Foo_street_2', 'number' => 15, 'box' => 'Foo_box', 'district' => 'Foo_district', 'postal_code' => 'Foo_postal_code', 'city' => 'Foo_city', 'country' => 'us', 'latitude' => 'Foo_latitude', 'longitude' => 'Foo_longitude'));
     $address->save();
     $input = array('street_1' => 'Bar_street_1', 'street_2' => 'Bar_street_2', 'number' => 17, 'box' => 'Bar_box', 'district' => 'Bar_district', 'postal_code' => 'Bar_postal_code', 'city' => 'Bar_city', 'country' => 'be', 'latitude' => 'Bar_latitude', 'longitude' => 'Bar_longitude');
     $this->addressFactory->modify($address, $input);
     $addressRepository = App::make('\\App\\Repositories\\Eloquent\\EloquentAddressRepository');
     $this->assertEquals(1, $addressRepository->all()->count());
     $this->assertEquals('Bar_street_1', $addressRepository->all()->first()->street_1);
 }
コード例 #6
0
 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';
 }
コード例 #7
0
 /**
  * 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]);
 }
コード例 #8
0
 private function createAddress()
 {
     $address = new Address();
     $address->region = "";
     $address->city = "";
     $address->district = "";
     $address->street = "";
     $address->home = "";
     $address->housing = "";
     $address->building = "";
     $address->metro = "";
     $address->latitude = 0;
     $address->longitude = 0;
     $address->save();
     return $address->id;
 }
コード例 #9
0
 /**
  * Creates a new DocRegistration model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new DocRegistration();
     $address = new Address();
     if ($model->load(Yii::$app->request->post()) && $address->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->addFlash('success', "Регистрация \"{$model->fullNum}\" успешно добавлена.");
         return $this->redirect(Url::previous() != Yii::$app->homeUrl ? Url::previous() : ['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->referrer != Yii::$app->request->absoluteUrl) {
             Url::remember(Yii::$app->request->referrer ? Yii::$app->request->referrer : null);
         }
         if (!Yii::$app->request->isPost) {
             $model->setAttributes(Yii::$app->request->get());
         }
         return $this->render('create', ['model' => $model, 'address' => $address]);
     }
 }
コード例 #10
0
 public function run()
 {
     DB::table('addresses')->delete();
     $collection = [['company_id' => 5, 'country_id' => 1, 'type' => 'business', 'address1' => '5350 Poplar Ave Suite 150', 'address2' => '', 'city' => 'Memphis', 'state' => 'TN', 'postal_code' => '38119'], ['company_id' => 2, 'country_id' => 1, 'type' => 'business', 'address1' => '6750 Poplar Ave Suite 500', 'address2' => '', 'city' => 'Memphis', 'state' => 'TN', 'postal_code' => '38138']];
     foreach ($collection as $record) {
         Address::create($record);
     }
 }
コード例 #11
0
 /**
  * Delete an Address.
  *
  * @param string $id
  *
  * @return Redirect
  */
 public function destroy(Request $request, $id)
 {
     // delete
     $address = Address::find($id);
     $address->delete();
     // redirect
     $request->session()->flash('success', trans('address.address') . ' ' . trans('crud.deleted'));
     return back();
 }
コード例 #12
0
ファイル: CartController.php プロジェクト: irying/artist
 public function actionAddress($id = null)
 {
     if ($id) {
         $model = Address::findOne($id);
         if ($model === null) {
             throw new NotFoundHttpException('model does not exist.');
         }
     } else {
         $model = new Address();
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         if ($model->save()) {
             return $this->redirect(['cart/checkout']);
         }
     }
     return $this->render('address', ['model' => $model]);
 }
コード例 #13
0
ファイル: UserController.php プロジェクト: sushilcs111/td
 public function add_address()
 {
     $address = new Address();
     //dd(Session::get("userId"));
     $address->user_id = Session::get('user')->id;
     $address->firstname = Input::get('cname');
     $address->lastname = Input::get('lname');
     $address->phone = Input::get('phone');
     $address->address1 = Input::get('address1');
     $address->address2 = Input::get('address2');
     $address->address3 = Input::get('address3');
     $address->pincode = Input::get('pincode');
     $address->city = Input::get('city');
     $address->country = Input::get('country');
     $address->save();
     $addid = $address->id;
     // dd($addid);
     return redirect()->back();
 }
コード例 #14
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Address::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
コード例 #15
0
 public function searchResult()
 {
     $searchWord = Input::get('search', '');
     $maxCount = (int) Input::get('max_count', 100);
     $addr = new Models\Address();
     /** @var \Illuminate\Database\Query\Builder $q */
     $q = $addr->newQuery();
     $decoded_searchWord = Models\Address::processZip($searchWord);
     $q->orWhere('zip', '=', $decoded_searchWord);
     foreach (['ken_furi', 'city_furi', 'town_furi'] as $col) {
         Models\Address::filterQueryFuri($searchWord, $q, $col);
     }
     foreach (['ken_name', 'city_name', 'town_name', 'kyoto_street', 'block_name'] as $col) {
         Models\Address::filterQueryKanji($searchWord, $q, $col);
     }
     /** @var \Illuminate\Database\Eloquent\Collection|static[] $results */
     $results = $q->take($maxCount)->get(['ken_id', 'zip', 'ken_name', 'ken_furi', 'city_name', 'city_furi', 'town_name', 'town_furi', 'kyoto_street', 'block_name', 'office_name', 'office_address']);
     $resultCount = count($results);
     return view('index', ['results' => $results, 'count' => $resultCount, 'searchWord' => $searchWord, 'maxCount' => $maxCount]);
 }
コード例 #16
0
 public function update($id, Request $request)
 {
     $address = Address::find($id);
     $rules = $address->getValidatorRules();
     $validator = $this->validate($request, $rules);
     if ($validator) {
         return response()->json($validator, '404');
     }
     $input = $request->all();
     $address->update($input);
     $address->save();
     return $address;
 }
コード例 #17
0
ファイル: AddressBehavior.php プロジェクト: slavam/placement
 public function saveRelatedDir($txt, $id_field, $name_field, $classDir)
 {
     $id = $this->owner->{$id_field};
     $model = $id ? Address::findOne($id) : new $classDir();
     if ($model->load(\Yii::$app->request->post())) {
         if (!$model->save()) {
             $this->addError($id_field, 'Не удалось сохранить новое значение');
             return false;
         }
         $this->owner->{$id_field} = $model->id;
         return true;
     }
 }
コード例 #18
0
ファイル: AddressSearch.php プロジェクト: slavam/placement
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Address::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'region_id' => $this->region_id, 'city_id' => $this->city_id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
     $query->andFilterWhere(['like', 'street', $this->street])->andFilterWhere(['like', 'house', $this->house])->andFilterWhere(['like', 'room', $this->room])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
コード例 #19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Address::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['address_id' => $this->address_id, 'user_fk' => $this->user_fk, 'country_fk' => $this->country_fk, 'city_fk' => $this->city_fk, 'last_update' => $this->last_update]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address]);
     return $dataProvider;
 }
コード例 #20
0
 /**
  * Creates new user in database and fire an event for
  * sneding activation mail
  * @param  RegistrationRequest $request
  * @return Response
  */
 public function postRegister(RegistrationRequest $request)
 {
     $input = $request->except('repeat_password');
     if ($input['country_id'] != 840) {
         $input['state_id'] = null;
     }
     $input['code'] = str_random(30);
     $input['password'] = Hash::make($request['password']);
     $address = Address::create($input);
     $input['address_id'] = $address->id;
     $user = User::create($input);
     Event::fire(new UserIsRegistered($user));
     return redirect(route('StoreUserLoginGet'))->with('flag', 'activationSent');
 }
コード例 #21
0
ファイル: MyController.php プロジェクト: ThunderID/SHOP-API
 /**
  * Display my addresses
  *
  * @return Response
  */
 public function addresses($user_id = null)
 {
     $result = \App\Models\Address::ownerid($user_id)->ownertype('App\\Models\\Customer');
     $count = $result->count();
     if (Input::has('skip')) {
         $skip = Input::get('skip');
         $result = $result->skip($skip);
     }
     if (Input::has('take')) {
         $take = Input::get('take');
         $result = $result->take($take);
     }
     $result = $result->get()->toArray();
     return new JSend('success', (array) ['count' => $count, 'data' => $result]);
 }
コード例 #22
0
 public function search($input)
 {
     $query = Address::query();
     $columns = Schema::getColumnListing('addresses');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
コード例 #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(Request::all(), ['name' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         try {
             $person = new Person();
             $person->name = Input::get('name');
             $person->last_name = Input::get('last_name');
             $person->document = Input::get('document') == '' ? null : Input::get('document');
             $person->identity = Input::get('identity') == '' ? null : Input::get('identity');
             $person->email = Input::get('email') == '' ? null : Input::get('email');
             $person->birthdate = Input::get('birthdate');
             $person->nationality = Input::get('nationality');
             $person->gender = Input::get('gender');
             $person->phone = Input::get('phone');
             $person->phone_cel = Input::get('phone_cel');
             $person->name = Input::get('name');
             $person->name = Input::get('name');
             $person->save();
             $member = new Member();
             $member->father = Input::get('father');
             $member->mother = Input::get('mother');
             $member->marital_status_id = Input::get('marital_status_id');
             $member->date_baptism = Input::get('date_baptism');
             $member->occupacion = Input::get('occupacion');
             $member->function_id = Input::get('function_id');
             $member->literacy_id = Input::get('literacy_id');
             $member->person_id = $person->id;
             $member->save();
             $address = new Address();
             $address->address = Input::get('address');
             $address->number = Input::get('number');
             $address->complement = Input::get('complement');
             $address->zip_code = Input::get('zip_code');
             $address->reference = Input::get('reference');
             $address->country = Input::get('country');
             $address->state = Input::get('state');
             $address->city = Input::get('city');
             $address->person_id = $person->id;
             $address->save();
             return redirect('members');
         } catch (\Illuminate\Database\QueryException $e) {
             print_r($e->errorInfo);
         }
     }
 }
コード例 #24
0
 public function actionGetCard($cid)
 {
     $company = Company::find()->where(['id' => $cid])->asArray()->one();
     $address = Address::find()->where(['id' => $company['address_id']])->asArray()->one();
     $shedule = Shedule::find()->where(['company_id' => $cid])->asArray()->all();
     $brand = Company::find()->where(['id' => $cid])->one()->brand;
     $service = Company::find()->where(['id' => $cid])->one()->service;
     $srv = ArrayHelper::getColumn($service, 'category_id');
     $category = Category::find()->where(['id' => $srv])->asArray()->indexBy('id')->all();
     $srv = ArrayHelper::map($service, 'id', 'name', 'category_id');
     $spoffer = SpecialOffer::find()->where(['company_id' => $cid])->asArray()->one();
     $file = Files::find()->where(['id' => $spoffer['file_id']])->asArray()->one();
     Yii::$app->response->format = Response::FORMAT_JSON;
     $response = ['company' => $company, 'address' => $address, 'shedule' => $shedule, 'brand' => $brand, 'category' => $category, 'service' => $srv, 'spoffer' => $spoffer, 'file' => $file];
     return $response;
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 /**
  * Proccess payment
  *
  * @param  Request $request
  * @return Response
  */
 public function pay(Request $request)
 {
     $user = Auth::user();
     if ($request->session()->has('addressId')) {
         $address = Address::find($request->session()->get('addressId'));
         $request->session()->forget('addressId');
     } else {
         $address = $user->address;
     }
     // array for order data
     $orderData = [];
     $orderData['full_price'] = Cart::totalWithShipping();
     $orderData['user_id'] = $user->id;
     $orderData['address_id'] = $address->id;
     if ($request->has('stripeToken')) {
         \Stripe\Stripe::setApiKey(env('STRIPE_TEST_SECRET_KEY'));
         $orderData['stripeToken'] = $request->get('stripeToken');
         $orderData['payment_method_id'] = 1;
         try {
             $charge = \Stripe\Charge::create(array("amount" => $orderData['full_price'] * 100, "currency" => "usd", "source" => $orderData['stripeToken'], "description" => "Test charge; user e-mail: " . $user->email));
         } catch (\Stripe\Error\Card $e) {
             $request->session()->flash('status', 'Card declined, please fill your card and try again later.');
             return redirect('/');
         }
     } else {
         $orderData['payment_method_id'] = 2;
     }
     $cartProducts = \Cart::associate('Product', 'App\\Models')->content();
     $products = new Collection();
     foreach ($cartProducts as $item) {
         $products->push(['product' => \App\Models\Product::find($item->id), 'quantity' => $item->qty]);
     }
     // Get the order weight
     $orderData['weight'] = 0;
     foreach ($products as $product) {
         $orderData['weight'] += $product['product']->weight * $product['quantity'];
     }
     $order = Order::create($orderData);
     foreach ($products as $product) {
         OrderProduct::create(['order_id' => $order->id, 'product_id' => $product['product']->id, 'quantity' => $product['quantity'], 'price' => (double) $product['product']->price * $product['quantity']]);
     }
     Event::fire(new OrderWasPlaced($order));
     Cart::destroy();
     $request->session()->flash('status', 'Order recieved.');
     return redirect('/');
 }
コード例 #27
0
ファイル: AddressSearch.php プロジェクト: vab777/marts.id_be
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Address::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith(['country', 'province', 'customer']);
     //$query->joinWith('country');
     //$query->joinWith('province');
     //$query->joinWith('customer');
     $query->andFilterWhere(['address_id' => $this->address_id, 'address_category' => $this->address_category, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'country_name', $this->country_id])->andFilterWhere(['like', 'province_name', $this->province_id])->andFilterWhere(['like', 'first_name', $this->customer_id])->andFilterWhere(['like', 'address_1', $this->address_1])->andFilterWhere(['like', 'address_2', $this->address_2])->andFilterWhere(['like', 'postcode', $this->postcode])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'phone_1', $this->phone_1])->andFilterWhere(['like', 'phone_2', $this->phone_2])->andFilterWhere(['like', 'other', $this->other]);
     return $dataProvider;
 }
コード例 #28
0
ファイル: CheckoutController.php プロジェクト: sushilcs111/td
 public function secure()
 {
     $user = User::find(Session::get('user')->id);
     $user->firstname = Input::get('cname');
     $user->lastname = Input::get('lname');
     $user->phone = Input::get('phone');
     if ($user->Update()) {
         $address = Address::find($user->addresses()->first()->id);
         $address->user_id = $user->id;
         $address->firstname = Input::get('cname');
         $address->lastname = Input::get('lname');
         $address->address1 = Input::get('address1');
         $address->address2 = Input::get('address2');
         $address->address3 = Input::get('address3');
         $address->pincode = Input::get('pincode');
         $address->city = Input::get('city');
         $address->country = Input::get('country');
         $address->Update();
         //  return view('frontend.pages.checkout-details', compact('address'));
     }
     return redirect()->route('checkout_info');
 }
コード例 #29
0
 public function testFilterKanji()
 {
     $kanji = '新宿';
     $trueColumns = ['city_name', 'town_name'];
     $falseColumns = ['ken_name'];
     foreach ($trueColumns as $trueColumn) {
         /** @var \Illuminate\Database\Query\Builder $q */
         $addr = new \App\Models\Address();
         $q = $addr->newQuery();
         \App\Models\Address::filterQueryFuri($kanji, $q, $trueColumn);
         $result = $q->get(['id']);
         self::assertTrue(count($result) > 0);
     }
     foreach ($falseColumns as $falseColumn) {
         /** @var \Illuminate\Database\Query\Builder $q */
         $addr = new \App\Models\Address();
         $q = $addr->newQuery();
         \App\Models\Address::filterQueryFuri($kanji, $q, $falseColumn);
         $result = $q->get(['id']);
         self::assertTrue(count($result) === 0);
     }
 }
コード例 #30
0
 /**
  * 依据前台post消息创建订单
  *
  * @param Request $request
  * @return \Response
  */
 public function generateConfig(Request $request)
 {
     $validator = \Validator::make($request->all(), ['address_id' => 'required|exists:addresses,id', 'cart' => 'required']);
     if ($validator->fails()) {
         return response()->json($validator->errors()->getMessages());
     }
     $customer = \Helper::getCustomer();
     $items = $request->input('cart');
     $sale = $request->input('sale', null);
     if ($sale != null && !$this->checkSaleCredential($customer, $sale)) {
         return response()->json(['success' => false, 'error_message' => '你不具有参加特卖资格!']);
     }
     $order = new Order();
     $address = Address::findOrFail($request->input('address_id'));
     $order->initWithCustomerAndAddress($customer, $address, $sale);
     $order->save();
     $order->addCommodities($items);
     $order->calculate();
     $order->save();
     $result = \Wechat::generatePaymentConfig($order, $customer);
     return response()->json(['success' => true, 'data' => ['result' => $result, 'order_id' => $order->id]]);
 }