Exemplo n.º 1
0
 public static function getHtmlByOutlet($addressId)
 {
     $address = Address::find($addressId);
     if (!empty($address)) {
         return Address::where('city_id', $address->city_id)->lists('address', 'id');
     }
     return null;
 }
Exemplo n.º 2
0
 public function getCheckout()
 {
     // Get the bag items.
     $bag = Bag::with('product.product_media.media')->where('user_id', '=', Auth::user()->id)->get();
     // Get the cards.
     $cards = Stripe::getCards();
     // Get the addresses.
     $addresses = Address::where('user_id', '=', Auth::user()->id)->get();
     // Render the view.
     return View::make('brochure.my.checkout', ['bag' => $bag, 'cards' => $cards->data, 'addresses' => $addresses]);
 }
Exemplo n.º 3
0
 /**
  * Update the specified outlet in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $retailer = Retailer::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Retailer::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $retailer->update($data);
     $countries = Country::lists('country', 'id');
     $cities = City::where('country_id', $retailer->country_id)->lists('city', 'id');
     $addresses = Address::where('city_id', $retailer->city_id)->lists('address', 'id');
     $cats = BusinessCategory::lists('name', 'id');
     return Redirect::to('admin/retailers/' . $retailer->id . '/edit')->with('success', 'Update retailer');
 }
 protected function refreshAllBalances()
 {
     // find all addresses by id
     $xchain = app('Tokenly\\XChainClient\\Client');
     $xchain_balances = PlatformAdminMeta::get('xchain_balances', []);
     foreach ($xchain_balances as $xchain_balance) {
         Log::debug("refreshAllBalances \$xchain_balance['id']=" . json_encode($xchain_balance['id'], 192));
         foreach (Address::where('xchain_address_id', $xchain_balance['id'])->get() as $address) {
             // delete all balances
             Log::debug("deleting from address_balances WHERE address_id={$address->id}");
             DB::table('address_balances')->where('address_id', $address->id)->delete();
             // update balances
             $balances = $xchain->getBalances($address->address, true);
             if ($balances and count($balances) > 0) {
                 Address::updateAddressBalances($address->id, $balances);
             }
         }
     }
 }
Exemplo n.º 5
0
 public function getMyaddress()
 {
     $user_id = Auth::user()->id;
     $base_address = User::where('id', '=', $user_id)->get(array('address'))->toArray();
     $other_add = Address::where('user_id', '=', $user_id)->get()->toArray();
     return View::make('users.myaddress')->with('base_address', $base_address)->with('other_add', $other_add);
 }
Exemplo n.º 6
0
 public function newAddress()
 {
     $input = Input::all();
     $address = new Address();
     if (Input::has('id')) {
         $address = Address::where('id', $input['id'])->first();
     }
     $address->address = $input['address'];
     $address->save();
     return Response::json(array('address' => $address));
 }
Exemplo n.º 7
0
 /**
  * Edits a user
  * @var User
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(User $user)
 {
     $oldUser = clone $user;
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $user->phone_number = Input::get('phone_number');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password != $passwordConfirmation) {
             // Redirect to the new user page
             $error = Lang::get('admin/users/messages.password_does_not_match');
             return Redirect::to('user')->with('error', $error);
         } else {
             $user->password = $password;
             $user->password_confirmation = $passwordConfirmation;
         }
     }
     $data = array('city_id' => Input::get('city_id'), 'address' => Input::get('address'));
     if ($user->address_id) {
         Address::where('id', $user->address_id)->update($data);
     } else {
         $address = Address::create($data);
         $user['address_id'] = $address->id;
     }
     if ($this->userRepo->save($user)) {
         return Redirect::to('user/profile/' . $user->username)->with('success', Lang::get('user/user.user_account_updated'));
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->with('error', $error);
     }
 }
Exemplo n.º 8
0
 /**
  * Set value of a flag. Unsets all other addresses for that user.
  * Called by using Addresses::setFlagname($address)
  *
  * @param mixed $objectOrId primary address id or object instance
  */
 private function setFlag($address)
 {
     if (!is_object($address)) {
         $address = Address::find($address);
     }
     if ($userId = $address->user_id) {
         Address::where('user_id', '=', self::userId())->update(array('is_billing' => false));
         $address->{'is_billing'} = true;
         $address->save();
     }
 }
 /**
  * Process the user's order through to payment.
  *
  * @param  int  $id
  * @return Response
  */
 public function checkout()
 {
     // If user is not logged in, then re-direct to log in.
     if (Auth::guest()) {
         // Set a session variable to indicate that we are in the
         // checkout process.
         Session::put('checkOutInProgress', TRUE);
         //Redirect::route('login');
         return Redirect::route('customers.create')->with('message', 'Please create a customer profile.');
     }
     // If user is logged in, but doesn't have address and is ordering
     // physical media (not MP3s ONLY!), then re-direct to add address.
     if (Auth::check()) {
         $query = Address::where('customer_id', '=', Auth::id());
         $addr = $query->get()->first();
         if (!$addr->id) {
             Redirect::route('customers.address.create', array('id' => Auth::id()))->with('message', 'Please enter your address to complete the checkout process.');
         }
     }
     // If everything with customer and address is good, we re-direct
     // to creating the shell order, including choosing shipping method
     // and any notes.
     return Redirect::route('orders.create');
     //OrdersController::createShellOrder();
     //OrdersController::persistCart();
 }
Exemplo n.º 10
0
 public function comment()
 {
     $address = Address::where('id', Input::get('address_id'))->first();
     $body = Input::get('body');
     $address_id = Input::get('address_id');
     $user_name = DB::table('users')->where('id', Input::get('user_id'))->pluck('username');
     $comment = new Comment();
     $comment->body = Input::get('body');
     $comment->user_id = Input::get('user_id');
     $comment->address_id = Input::get('address_id');
     $comment->comment_parent = Input::get('comment_parent');
     $address->comments()->save($comment);
     Mail::send('emails.comment', compact('body', 'address_id', 'user_name'), function ($message) {
         $user_email = DB::table('users')->where('id', Input::get('user_id'))->pluck('email');
         $user_name = DB::table('users')->where('id', Input::get('user_id'))->pluck('username');
         $message->to($user_email, 'Well Basically')->subject('User ' . $user_name . ' commented on Your Well!');
     });
     return Redirect::back();
 }
Exemplo n.º 11
0
 /**
  * Update the specified outlet in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($outlet)
 {
     $data = Input::except('summary');
     $description = Input::only('full_description', 'summary');
     $validator = Validator::make($data = Input::all(), Outlet::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if ($outlet->description_id) {
         $desc = OutletDescription::where('id', $outlet->description_id)->update($description);
     } else {
         $desc = OutletDescription::create($description);
         $data['description_id'] = $desc->id;
     }
     $addressData = array('city_id' => $data['city_id'], 'address' => $data['address']);
     if ($outlet->address_id) {
         $address = Address::where('id', $outlet->address_id)->update($addressData);
     } else {
         $address = Address::create($addressData);
         $data['address_id'] = $address->id;
     }
     unset($data['full_description']);
     unset($data['address']);
     $data['status'] = 'active';
     if ($outlet->update($data)) {
         return Redirect::to('outlet')->with('success', Lang::get('site/outlets/messages.update.success'));
     }
     return Redirect::route('outlet.edit')->with('error', Lang::get('site/outlets/messages.update.error'));
 }
Exemplo n.º 12
0
    $editAddress->neighborhood = $neighborhood;
    $editAddress->city = $city;
    $editAddress->state = $state;
    if ($editAddress->save()) {
        $data['msg'] = 'Address saved successfully!';
        $data['id'] = $editAddress->id;
    } else {
        $data['msg'] = 'An error occurred while saving the address!';
    }
    $contactList->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
// Delete address
$contactList->delete("/addresses/:id", function ($id) use($contactList) {
    $address = Address::find($id);
    $countAddress = Address::where('contactId', '=', $address->contactId)->count();
    if ($countAddress > 1) {
        if ($address->delete()) {
            $data['msg'] = 'Address deleted successfully!';
        } else {
            $data['msg'] = 'An error occurred while deleting the address!';
        }
    } else {
        $data['msg'] = 'The contact should have at least one address!';
    }
    $contactList->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
// Check email address
$contactList->post("/checkemail", function () use($contactList) {
    $email = $contactList->request->params('email');
Exemplo n.º 13
0
 /**
  * Create a new address using post array data
  *
  * @param array $data
  * @return object $address or null
  */
 public function createAddress($data = null)
 {
     if (is_null($data)) {
         $data = \Input::all();
     }
     if (Auth::user()->check()) {
         $address = Address::where($data)->first();
         if ($address) {
             return $address;
         }
     }
     return Address::create($data);
 }