コード例 #1
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();
 }
コード例 #2
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;
 }
コード例 #3
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;
 }
コード例 #4
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;
 }
コード例 #5
0
ファイル: CartController.php プロジェクト: irying/artist
 public function actionCheckout()
 {
     $userId = Yii::$app->user->id;
     $addresses = Address::find()->where(['user_id' => $userId])->all();
     $model = new Order();
     $products = Cart::find()->where(['session_id' => Yii::$app->session->id])->all();
     if (!count($products)) {
         return $this->redirect('/cart');
     }
     if (count($addresses)) {
         return $this->render('checkout', ['model' => $model, 'addresses' => $addresses, 'products' => $products]);
     } else {
         return $this->redirect(['cart/address']);
     }
 }
コード例 #6
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;
 }
コード例 #7
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;
 }
コード例 #8
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('/');
 }
コード例 #9
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;
 }
コード例 #10
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');
 }
コード例 #11
0
 /**
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function update(Request $request)
 {
     $validator = \Validator::make($request->all(), ['id' => 'required|exists:addresses', 'phone' => 'digits:11']);
     if ($validator->fails()) {
         return response()->json(['success' => false, 'error_messages' => $validator->errors()->getMessages()]);
     }
     $customer = \Helper::getCustomer();
     $address = Address::find($request->input('id'));
     if ($address->customer_id != $customer->id) {
         return response()->json(['success' => false, 'error_messages' => 'not matched']);
     }
     //先重置所有default
     if ($request->has('is_default') and $request->input('is_default') == "true") {
         $customer->addresses()->update(['is_default' => false]);
     }
     Address::find($request->input('id'))->update($request->all());
     return response()->json(['success' => true, 'id' => $address->id]);
 }
コード例 #12
0
ファイル: User.php プロジェクト: NightWatch-BG/sglobka
 public function haveAddress()
 {
     return Address::find()->where(['user_fk' => $this->user_id])->one();
 }
コード例 #13
0
ファイル: _form.php プロジェクト: obedkin/atlant
$listdata = ArrayHelper::map(Department::find()->all(), 'id', 'title');
?>
        <?php 
echo $form->field($model, 'department_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>

        <?php 
$listdata = ArrayHelper::map(User::find()->all(), 'id', 'last_name');
?>
        <?php 
echo $form->field($model, 'user_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>


        <?php 
$listdata = ArrayHelper::map(Address::find()->all(), 'id', 'title');
?>
        <?php 
echo $form->field($model, 'address_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>

        <?php 
echo $form->field($model, 'place_id')->widget(DepDrop::classname(), ['options' => ['id' => 'place_id'], 'pluginOptions' => ['depends' => ['user-address_id'], 'placeholder' => 'Select...', 'url' => Url::to(['/place/list'])]]);
?>


        <?php 
echo $form->field($model, 'phone_work')->widget(MaskedInput::classname(), ['mask' => '8 (999) 999-99-99', 'clientOptions' => ['removeMaskOnSubmit' => true]]);
?>

        <?php 
コード例 #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Address::find($id)->delete();
     return redirect('persons');
 }
コード例 #15
0
 public function actionGetCoords()
 {
     $data = Yii::$app->request->post();
     $cityID = $data['city'];
     $city = City::findOne($cityID);
     $cityName = null;
     if ($city) {
         $cityName = $city->name;
     }
     $address = Address::find()->andFilterWhere(['city' => $cityName])->asArray()->all();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $responce = ['coords' => $address];
     return $responce;
 }
コード例 #16
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $item = \App\Models\Item::find($id);
     $document = \App\Models\Document::find($item->document_id);
     $type = $document->os_type;
     switch ($type) {
         case 'movables' || 'value_movables':
             $variable = \App\Models\Item::find($id)->variable();
             return View::make('item.edit', array('item' => $item, 'document' => $document, 'variable' => $variable));
             break;
         case 'car':
             $variable = \App\Models\Item::find($id)->variable();
             $car = \App\Models\Car::find($id)->car();
             return View::make('item.edit', array('item' => $item, 'document' => $document, 'variable' => $variable, 'car' => $car));
             break;
         case 'buildings':
             $variable = \App\Models\Item::find($id)->variable();
             $building = \App\Models\Item::find($id)->building();
             $address = \App\Models\Address::find($id)->address();
             return View::make('item.edit', array('item' => $item, 'document' => $document, 'building' => $building, 'variable' => $variable, 'address' => $address));
             break;
         case 'parcels':
             $parcel = \App\Models\Item::find($id)->parcel();
             $address = \App\Models\Address::find($id)->address();
             return View::make('item.edit', array('item' => $item, 'document' => $document, 'parcel' => $parcel, 'address' => $address));
             break;
     }
 }
コード例 #17
0
ファイル: AddressController.php プロジェクト: study-code/yii2
 function actionIndex()
 {
     $address = Address::find()->setCache(true)->asArray()->one();
     //Common::dump($address);
 }
コード例 #18
0
ファイル: SaveController.php プロジェクト: xiaojianxin/Ontee
 public function actionDeladdress()
 {
     $post = Yii::$app->request->post();
     $address = Address::find()->where(['id' => $post['addressId']])->one();
     if ($address->delete()) {
         echo "0";
     }
 }
コード例 #19
0
 public function addr_up(Request $request, $id)
 {
     $address = Address::find($id);
     $address->update($request->all());
     return redirect('/account');
 }
コード例 #20
0
ファイル: _fields.php プロジェクト: slavam/placement
?>

<?php 
/*echo $form->field($model, 'city_name')->widget(\kartik\select2\Select2::classname(), [
      'data' => \app\models\City::find()
          ->select(['name'])
          ->active()
          ->asArray()
          ->all(),
      'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP,
      'options' => ['placeholder' => 'Select a state ...'],
      'pluginOptions' => [
          'allowClear' => true
      ],
  ]);*/
?>

<?php 
echo $form->field($model, 'street')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Address::find()->select(['street'])->active()->distinct()->orderBy('street asc')->asArray()->all(), 'street', 'street'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'street', 'labelField' => 'street', 'searchField' => ['street']]])->hint('');
?>

<?php 
//echo $form->field($model, 'street')->textInput(['maxlength' => true])
?>

<?php 
echo $form->field($model, 'house')->textInput(['maxlength' => true]);
?>

<?php 
echo $form->field($model, 'room')->textInput(['maxlength' => true]);
コード例 #21
0
ファイル: CheckoutController.php プロジェクト: bhavs123/web
 public function deleteAddress()
 {
     $addressId = Input::get("addr_id");
     $address = Address::find($addressId)->delete();
     //    return
 }
コード例 #22
0
ファイル: SiteController.php プロジェクト: xiaojianxin/Ontee
 public function actionOrderconfirm()
 {
     $layout_data = array('username' => Yii::$app->session['username'], 'status' => 2);
     $this->layout_data = $layout_data;
     $cache = \Yii::$app->cache;
     $orderId = $cache['id'];
     $Order = Order::find()->where(['id' => $orderId])->one();
     $address = Address::find()->where(['id' => $Order->addressid])->one();
     return $this->render("orderconfirm", ['order' => $Order, 'address' => $address]);
 }