Esempio n. 1
0
 public function addAddress($address_line_1, $address_line_2, $address_city, $address_postcode)
 {
     $address = new Address();
     $address->line_1 = $address_line_1;
     $address->line_2 = $address_line_2;
     $address->city = $address_city;
     $address->postcode = $address_postcode;
     $address->save();
     $this->addresses()->save($address);
 }
Esempio n. 2
0
 public function __construct(\App\Address $address)
 {
     $this->addressId = $address->id;
     $this->regionId = $address->region->id;
     $this->name = $address->region->name . " " . $address->name;
     if ($address->stars()->count() > 0) {
         foreach ($address->stars()->get() as $star) {
             $this->centers[] = new centerStar($star->id);
         }
     }
     if ($address->centers()->count() > 0) {
         foreach ($address->centers()->get() as $center) {
             $this->centers[] = new centerMulti($center->id);
         }
     }
 }
Esempio n. 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Truncate
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     User::truncate();
     Admin::truncate();
     Customer::truncate();
     Address::truncate();
     Category::truncate();
     Product::truncate();
     Brand::truncate();
     Type::truncate();
     Image::truncate();
     DB::statement('TRUNCATE category_product;');
     Product::clearIndices();
     Product::reindex();
     //Unguard
     Model::unguard();
     //Call
     $this->call(UsersTableSeeder::class);
     $this->call(ProductsTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Esempio n. 4
0
 /**
  * Check whether a user is using an address
  * @param $address_id
  * @param $user_id
  * @return int
  */
 public function usage($address_id, $user_id)
 {
     if ($this->usage->where('address_id', '=', $address_id)->where('user', '=', $user_id)->first()) {
         return 1;
     }
     return 0;
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('client', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Client::findOrFail($id);
     });
     $router->bind('bank', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return BankDetail::findOrFail($id);
     });
     $router->bind('address', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Address::findOrFail($id);
     });
     $router->bind('property', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Property::findOrFail($id);
     });
     $router->bind('agreement', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return RentalAgreement::findOrFail($id);
     });
     //
 }
 /**
  * Display the specified resource.
  *
  * @param RentalAgreement $agreement
  * @return Response
  * @internal param int $id
  */
 public function show(RentalAgreement $agreement)
 {
     $address = Address::find($agreement->property_id);
     $client = Client::find($agreement->client_id);
     $owner = Client::find($agreement->owner_id);
     return view('agreement.showAgreement', compact('agreement', 'address', 'client', 'owner'));
 }
Esempio n. 7
0
 protected function findAddresses()
 {
     $this->newAddr = \App\Address::find($this->newId);
     $this->oldAddr = \App\Address::find($this->oldId);
     $this->result['addresses'] = 'found';
     $this->checkStars();
 }
Esempio n. 8
0
 public function getOffer(Request $request, $shop_id = 0, $offer_id = 0)
 {
     $business = Business::apiFind($shop_id);
     $offer = Offer::apiFind($shop_id, $offer_id);
     $address = Address::apiLast();
     session(['uri' => URL::full()]);
     return view('auth.business.offer', ['TITLE' => '商家项目', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => 'auth.business.offer', 'business' => $business, 'offer' => $offer, 'address' => $address]);
 }
Esempio n. 9
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $users = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'school_id' => $data['school_id']]);
     $users->schools()->attach($data['school_id']);
     $address = Address::create(['contact11' => $data['contact11']]);
     $users->addresses()->save($address);
     return $users;
 }
Esempio n. 10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $amount = 5;
     for ($i = 0; $i < $amount; $i++) {
         Address::create(['address' => $faker->streetAddress, 'user_id' => $i + 1, 'created_at' => $faker->date('Y-m-d H:i:s'), 'updated_at' => $faker->date('Y-m-d H:i:s')]);
     }
 }
Esempio n. 11
0
 /**
  * @return $this
  */
 public function meta()
 {
     $img_url = 'http://d14d0ey1pb5ifb.cloudfront.net/';
     $property = \App\Property::where(['meta_set' => 0, 'status' => '1'])->orderBy('package', 'DESC')->first();
     $address = \App\Address::where(['property_id' => $property->property_id])->first();
     $images = \App\Image::where(['property_id' => $property->property_id])->orderBy('pos', 'ASC')->get();
     return view('dashboard.meta')->with(compact(['property', 'address', 'images', 'img_url']));
 }
 public function run()
 {
     $types = AddressType::$types;
     $keys = array_keys($types);
     $faker = Factory::create();
     foreach (range(0, 30) as $index) {
         Address::create(['type' => $faker->randomElement($keys), 'street' => $faker->streetName, 'city' => $faker->city, 'country' => $faker->country, 'zip' => $faker->countryCode]);
     }
 }
Esempio n. 13
0
 public function addLocation(Request $request)
 {
     $addressData = $this->formAddress($request);
     $addressData['shop_id'] = $request->get('shop_id');
     $addressData['open_from'] = $request->get('open_from');
     $addressData['open_to'] = $request->get('open_to');
     $locId = Address::addLocation($addressData);
     return Response::json($locId);
 }
Esempio n. 14
0
 /**
  * attempts to find a matching address before creating a new instance
  */
 public static function retrieveOrCreate(array $attributes = [])
 {
     // TODO: look up address attributes to find a match
     $existing_addr = Address::where('street', $attributes['street'])->where('city', $attributes['city'])->where('state', $attributes['state'])->where('zip1', $attributes['zip1'])->first();
     if ($existing_addr) {
         return $existing_addr;
     }
     return Address::create($attributes);
 }
Esempio n. 15
0
 public function run()
 {
     Address::truncate();
     Address::create(['user_id' => '1', 'address1' => 'T Nagar', 'address2' => 'New York', 'city' => 'Melbourne', 'state' => 'Dubai', 'country' => 'USA', 'pin' => '4213456', 'phone' => '7234556', 'landmark' => 'Lifes easy']);
     Address::create(['user_id' => '2', 'address1' => 'Anna Nagar', 'address2' => 'Yorkshire', 'city' => 'canberra', 'state' => 'Chennai', 'country' => 'UFA', 'pin' => '43433', 'phone' => '533336', 'landmark' => 'world easy']);
     Address::create(['user_id' => '3', 'address1' => 'Srinagar', 'address2' => 'New Jersey', 'city' => 'Stockholm', 'state' => 'Dublin', 'country' => 'SA', 'pin' => '13456', 'phone' => '4556', 'landmark' => 'Lifes Tough']);
     Address::create(['user_id' => '4', 'address1' => 'Tilak Nagar', 'address2' => 'New Delhi', 'city' => 'Qatar', 'state' => 'New Castle', 'country' => 'Canada', 'pin' => '456', 'phone' => '756', 'landmark' => 'Too easy']);
     Address::create(['user_id' => '5', 'address1' => 'Nagar', 'address2' => 'York', 'city' => 'bourne', 'state' => 'Duai', 'country' => 'SAE', 'pin' => '42456', 'phone' => '756', 'landmark' => 'Lifes!!!!!!!!!!!!']);
 }
Esempio n. 16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // We want to delete the table if it exists before running the seed
     DB::table('address')->delete();
     $seederData = array(['text' => 'We offer you awesome tours', 'address' => 'Moonshine St. 14/05 Light, Jupiter', 'phone' => '+00 (123) 456 78 90', 'mail' => '*****@*****.**']);
     foreach ($seederData as $item) {
         Address::create($item);
     }
 }
Esempio n. 17
0
 public function run()
 {
     $faker = Faker::create();
     //Category
     for ($i = 0; $i < 10; $i++) {
         $user = User::select(['id'])->where('id', rand(1, User::count()))->first();
         $address = Address::create(['user_id' => $i <= 2 ? 4 : $user->id, 'default' => 0, 'line1' => $faker->streetAddress, 'line2' => $faker->streetAddress, 'phone' => $faker->e164PhoneNumber, 'name_contact' => $faker->streetName, 'zipcode' => $faker->postcode, 'city' => $faker->city, 'country' => $faker->country, 'state' => $faker->state]);
     }
 }
Esempio n. 18
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $addressId = $request->segments()[2];
     $addrUser = Address::find($addressId);
     // if ($addrUser->user_id != Auth::user()->id)
     // {
     //     return redirect('profile')->with('danger', 'This address is not associated with you.');
     // }
     return $next($request);
 }
Esempio n. 19
0
 public function getIndex(Request $request)
 {
     $address = \App\Address::where('user_id', '=', \Auth::id())->get()->first();
     if (is_null($address)) {
         \Session::flash('flash_message', 'Please create an address for your account');
         return redirect('addresses/create');
     }
     $accounts = \App\Account::where('user_id', '=', \Auth::id())->orderBy('id', 'ASC')->get();
     return view('account.index')->with('accounts', $accounts);
 }
Esempio n. 20
0
 public static function updateAddress($address)
 {
     try {
         $addressObj = Address::findOrFail($address['id']);
         $data = $addressObj->update(['lat' => $address['lat'], 'long' => $address['long']]);
     } catch (Exception $e) {
         $data = ['error' => 'Address not updated', 'message' => $e->getMessage()];
     }
     return $data;
     // dd(['$address' => $address, 'updated' => $data, 'addressObj' => $addressObj->toArray()]); exit;
 }
Esempio n. 21
0
 private function validateAndSaveConsumer(Request $request, Consumer $consumer)
 {
     $this->validate($request, array_merge(['first_name' => 'required', 'last_name' => 'required', 'description' => 'required'], Address::rules()));
     // TODO: check to see if logged in user is a caregiver for this consumer
     $consumer->first_name = $request->first_name;
     $consumer->last_name = $request->last_name;
     $consumer->description = $request->description;
     $consumer->address_id = Address::retrieveOrCreate(['street' => $request->street, 'city' => $request->city, 'state' => $request->state, 'zip1' => $request->zip1])->id;
     $consumer->save();
     return Redirect::to('/caregiver');
 }
Esempio n. 22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $statuses = OrderStatus::$statuses;
     $keys = array_keys($statuses);
     $faker = Factory::create();
     $users = User::lists('id');
     $addresses = Address::lists('id');
     foreach (range(1, 30) as $index) {
         Order::create(['user_id' => $faker->randomElement($users), 'address_id' => $addresses[$index], 'status' => $faker->randomElement($keys), 'processed_on' => $faker->unixTime, 'shipped_on' => $faker->unixTime, 'expected_delivery_on' => $faker->unixTime, 'delivered_on' => $faker->unixTime]);
     }
 }
Esempio n. 23
0
 public function addresses($location, $sub_location)
 {
     /*
     $addresses = Address::where('location_id', $location)
     	->where('sub_location_id',$sub_location)
     	->lists('name_eng', 'id');
     */
     $addresses = Address::where('location_id', $location)->where('sub_location_id', $sub_location)->get()->map(function ($key) {
         return ['text' => $key->name_eng, 'value' => $key->id];
     })->toArray();
     return $addresses;
 }
Esempio n. 24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['contact11' => 'integer|min:1000000000|max:9999999999', 'contact12' => 'integer|max:9999999999', 'std_pincode' => 'integer']);
     $studentData = Student::findOrFail($id);
     $studentAdds = $studentData->addresses->flatten()->toArray();
     foreach ($studentAdds as $key => $value) {
         $studentAdd = $value;
     }
     $addressData = Address::findOrFail($studentAdd['id']);
     $addressData->update(['contact11' => $request->contact11, 'contact12' => $request->contact12, 'add1' => ucwords($request->add1), 'add2' => ucwords($request->add2), 'street' => ucwords($request->street), 'pincode' => $request->pincode]);
     return Redirect::route('student.show', ['student' => $addressData]);
 }
Esempio n. 25
0
 private function __construct($id)
 {
     $this->address = \App\Address::find($id);
     $this->stars = $this->address->stars()->get();
     $this->findPlanets();
     if ($this->centers = $this->address->centers()->count() > 0) {
         $this->centers = $this->address->centers()->get();
         $this->findBaryPlanets();
     }
     $this->findings = $this->address->discoveries()->get();
     $this->terminate();
 }
Esempio n. 26
0
 public function Geocoding()
 {
     //take addresses not yet scraped in the past or incorrectly scraped, geocode scraping, save to cities table
     $addressesWithoutGeolocation = Address::whereNull('city_id')->get();
     $GeoScraped = new GoogleMapsScraper();
     foreach ($addressesWithoutGeolocation as $address) {
         $gmaps_output = $GeoScraped->Geocode($address->raw_input);
         //get gmaps_status
         $dataArray['gmaps_status'] = null;
         $dataArray = parent::ExtractWithXpath($gmaps_output, $this->GeoPatterns, 'text', 'first', 'xml');
         //get address_components in array
         $componentsArray = array();
         $componentsArray = parent::ExtractWithXpath($gmaps_output, $this->AddressComponentsPattern, 'html', 'multiple', 'xml');
         $cityArray['city_name'] = null;
         $countryArray['country_code'] = null;
         $countryArray['country_name'] = null;
         //search country component in every address component, once found extract name and code
         foreach ($componentsArray as $AddressComponent) {
             if (preg_match("|type>country<|", $AddressComponent)) {
                 $AddressComponent = '<result>' . $AddressComponent . '</result>';
                 //get country_code, country_name
                 $countryArray = parent::ExtractWithXpath($AddressComponent, $this->CountryPatterns, 'text', 'first', 'xml');
             } elseif (preg_match("|type>natural_feature<|", $AddressComponent)) {
                 $AddressComponent = '<result>' . $AddressComponent . '</result>';
                 //get country_code, country_name
                 $cityArray = parent::ExtractWithXpath($AddressComponent, $this->IslandPatterns, 'text', 'first', 'xml');
             } elseif (preg_match("|type>locality<|", $AddressComponent)) {
                 $AddressComponent = '<result>' . $AddressComponent . '</result>';
                 //get country_code, country_name
                 $cityArray = parent::ExtractWithXpath($AddressComponent, $this->CityPatterns, 'text', 'first', 'xml');
             }
         }
         if (empty($cityArray['city_name']) and !empty($cityArray['island'])) {
             $cityArray['city_name'] = $cityArray['island'];
         }
         if (empty($countryArray['country_code'])) {
             $countryArray['country_code'] = 'xx';
         }
         //if city doesn't exist, save it to cities
         $city = City::firstOrNew(['city_name' => $cityArray['city_name'], 'country_code' => strtolower($countryArray['country_code'])]);
         $city->gmaps_status = $dataArray['gmaps_status'];
         $city->gmaps_output = $gmaps_output;
         $city->country_name = $countryArray['country_name'];
         //city_slug
         $slug = new SlugClass();
         $city->city_slug = $slug->slugify($cityArray['city_name']);
         $city->save();
         //save foreign key in addresses
         $address->city_id = $city->id;
         $address->save();
     }
 }
Esempio n. 27
0
 public function __construct(array $data)
 {
     parent::__construct($data);
     $this->address = \App\Address::find($data['address']);
     switch ($data['object']) {
         case 'star':
             $this->centerObject = \App\Star::find($data['objectId']);
             break;
         case 'multi':
             $this->centerObject = \App\Baricenter::find($data['objectId']);
             break;
     }
 }
Esempio n. 28
0
 public static function addLocation($data)
 {
     $shop_id = $data['shop_id'];
     $open_from = "";
     $open_to = "";
     $locId = null;
     unset($data['shop_id'], $data['open_from'], $data['open_to']);
     $addressId = Address::addAddress($data);
     if ($addressId != null) {
         $locData = array('address_id' => $addressId, 'shop_id' => $shop_id, 'open_from' => $open_from, 'open_to' => $open_to);
         $locId = Location::create($locData)->id;
     }
     return $locId;
 }
Esempio n. 29
0
 public function postEdit(Request $request)
 {
     $this->validate($request, ['streetaddress' => 'required', 'city' => 'required', 'state_id' => 'required', 'zip' => 'required', 'phone' => 'required']);
     $address = \App\Address::find($request->id);
     $address->streetaddress = $request->streetaddress;
     $address->streetaddress2 = $request->streetaddress2;
     $address->city = $request->city;
     $address->state_id = $request->state_id;
     $address->zip = $request->zip;
     $address->phone = $request->phone;
     //    $address->user_id = $request->user_id;
     $address->save();
     \Session::flash('flash_message', 'Your address was updated.');
     return redirect('/');
 }
Esempio n. 30
0
 /**
  * update the given user's profile info.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postUpdate(Request $request)
 {
     $this->validate($request, ['id' => 'required|exists:users']);
     $user = User::find($request->id);
     $user->email = $request->email;
     $this->validate($request, array_merge(['id' => 'required|exists:users', 'email' => 'email|max:255' . ($user->isDirty('email') ? '|unique:users,email' : '')], Address::rules()));
     if (Auth::user()->id != $request->id && !Auth::user()->administrator) {
         //todo: access denied (handle w/ middleware instead of controller?)
     } else {
         $user->first_name = $request->first_name;
         $user->last_name = $request->last_name;
         $user->address_id = Address::retrieveOrCreate(['street' => $request->street, 'city' => $request->city, 'state' => $request->state, 'zip1' => $request->zip1])->id;
         $user->save();
         return Redirect::to('/profile/' . $request->id);
     }
 }