/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function bulk_city_prov()
 {
     // Start Check Authorization
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('dashboard');
     }
     // End Check Authorization
     $data = RajaOngkir::Provinsi()->all();
     $citdat = RajaOngkir::Kota()->all();
     foreach ($data as $dat) {
         $province = new Province();
         // save category data into database //
         $province->id = $dat['province_id'];
         $province->name = $dat['province'];
         $province->save();
     }
     foreach ($citdat as $cdat) {
         $city = new City();
         $city->id = $cdat['city_id'];
         $city->id_provinces = $cdat['province_id'];
         $city->name_provinces = $cdat['province'];
         $city->name = $cdat['city_name'];
         $city->postal_code = $cdat['postal_code'];
         $city->type = $cdat['type'];
         $city->save();
     }
     Alert::success('Success Import Provinces and Cities !')->persistent("Close");
     return redirect('province/list')->with('message', 'You just imported !');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Model::unguard();
     //create a user
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = Hash::make('password');
     $user->save();
     //create a country
     $country = new Country();
     $country->name = "United States";
     $country->id = 236;
     $country->save();
     //create a state
     $state = new State();
     $state->name = "Pennsylvania";
     $state->id = 1;
     $state->save();
     $city = new City();
     $city->name = "Pittsburgh";
     $city->id = 1;
     $city->save();
     //create a location
     $location = new Location();
     $location->city_id = $city->id;
     $location->state_id = $state->id;
     $location->country_id = $country->id;
     $location->latitude = 40.44;
     $location->longitude = 80;
     $location->code = '15212';
     $location->address_1 = "100 Main Street";
     $location->save();
     //create a new accommodation
     $accommodation = new Accommodation();
     $accommodation->name = "Royal Plaza Hotel";
     $accommodation->location_id = $location->id;
     // $location->id;
     $accommodation->description = "A modern, 4-star hotel";
     $accommodation->save();
     //create a room
     $room1 = new App\Room();
     $room1->id = 1;
     $room1->room_number = 'A01';
     $room1->accommodation_id = $accommodation->id;
     $room1->save();
     //create another room
     $room2 = new Room();
     $room2->id = 2;
     $room2->room_number = 'A02';
     $room2->accommodation_id = $accommodation->id;
     $room2->save();
     //create the room array
     $rooms = [$room1, $room2];
     //$this->call('AuthorsTableSeeder');
     //$this->command->info('Authors table seeded!');
     //
     $this->call(AmenityTableSeeder::class);
     $this->command->info('Amenity Class Seeded table seeded!');
 }
Exemple #3
0
 /**
  * Find a site based on province, city and slug input
  *
  * @param string $province
  * @param string $city
  * @param string $slug
  *
  * @return mixed
  */
 public function findByProvinceCity($province, $city, $slug)
 {
     $p = new Province();
     $province = $p->where('slug', $province)->first();
     $c = new City();
     $city = $c->where(['province_id' => $province->id, 'slug' => $city])->first();
     $s = new Site();
     $site = $s->where(['city_id' => $city->id, 'slug' => $slug])->first();
     return $site;
 }
 public static function findOrCreate($data)
 {
     $city = self::where('name', $data['city'])->first();
     if (count($city) <= 0) {
         $city = new City();
         $city->name = $data['city'];
         $city->state_id = State::findOrCreate($data)->id;
         $city->save();
     }
     return $city;
 }
 public function run()
 {
     DB::statement("TRUNCATE TABLE cities CASCADE");
     $reader = Reader::createFromPath(base_path() . '/database/municipios.csv');
     foreach ($reader as $index => $row) {
         if (isset($row[1]) and isset($row[2]) and isset($row[3])) {
             $name = ucfirst(mb_strtolower($row[3], 'UTF-8'));
             $city = new City(['name' => $name, 'state_id' => $row[1]]);
             $city->id = $row[2];
             $city->save();
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['city' => 'required', 'country' => 'required|exists:countries,id']);
     $city = new City();
     $city->city = $request->city;
     $city->country_id = $request->country;
     $city->save();
     foreach ($request->language as $language_id) {
         $city->language()->attach($language_id);
     }
     $statusCode = 200;
     $response = ["success" => "City {$request->city} successfully created"];
     return response($response, $statusCode);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(City $city, CityStoreRequest $request)
 {
     $city = new City();
     $city->name = $request->input('name');
     $city->slug = strtolower($request->input('slug'));
     $city->geom = $request->input('lon') . ' ' . $request->input('lat');
     $city->state_id = $request->input('state_id');
     $city->facebook_id = $request->input('facebook_id');
     if ($city->save()) {
         Notification::success('Cidade editada!');
         return redirect()->route('cities.index');
     }
     Notification::error('Ops, falhou ao editar cidade.');
     return back();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $province_id = Input::get('province_id');
     $city_id = Input::get('city_id');
     $specialization_id = Input::get('specialization_id');
     $verified = Input::get('verified');
     $data = array();
     if (empty($province_id) && empty($city_id) && empty($specialization_id) && empty($verified)) {
         //menampilkan semua gender
         $data['content'] = \App\Doctor::all();
         $data['province_id'] = null;
         $data['city_id'] = null;
         $data['specialization_id'] = null;
         $data['verified'] = null;
     } else {
         $data['content'] = $data['province_id'] = $province_id;
         $data['city_id'] = $city_id;
         $data['specialization_id'] = $specialization_id;
         $data['verified'] = $verified;
     }
     $data['list_province'] = \App\Province::lists('name', 'id');
     $data['list_city'] = \App\City::lists('name', 'id');
     $data['list_specialization'] = \App\Specialization::lists('name', 'id');
     return view('pages.admin.clinic.doctor.index')->with('data', $data);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $brand = Brand::find($id);
     $cities = City::lists('city_name', 'id')->all();
     $brand_types = BrandType::lists('type_name', 'id')->all();
     return view('admin.brands.edit', compact('brand', 'cities', 'brand_types'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param Venue $venue
  * @return Response
  * @internal param int $id
  */
 public function edit(Venue $venue)
 {
     $features = Feature::lists('feature', 'id');
     $cities = City::lists('name', 'id');
     $types = Type::lists('type', 'id');
     return view('venues.edit', compact('venue', 'features', 'cities', 'types'));
 }
 public function remove(Request $request)
 {
     $oCity = City::find($request->id);
     $oCity->delete();
     $request->session()->flash('notify', ['type' => 'Success', 'text' => 'Данные успешно удалены!']);
     return redirect('city');
 }
 public static function processSiege(Army $army, City $city)
 {
     // TODO check if the army has catapult
     // TODO message users about the result
     $attack_point = $army->calculateAttackingPoints();
     $defense_point = $city->calculateDefensePoints();
     if ($attack_point > $defense_point) {
         // attacker wins
         // the city becomes the attacker's city
         $city->update(['owner' => $army->user->id, 'capital' => 0, 'nation' => $army->user->nation]);
         $city->hex->update(['owner' => $army->user->id]);
     } elseif ($attack_point < $defense_point) {
         // defender wins
         $army->destroyArmy();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->file('image')) {
         if ($request->file('image')->isValid()) {
             $fileName = (int) round(microtime(true) * 1000);
             $fileName .= '.' . $request->file('image')->guessExtension();
             $path = public_path() . '/img/uploads/';
             $request->file('image')->move($path, $fileName);
             $image = $fileName;
         }
     } else {
         $image = null;
     }
     $latitude = $request->input('latitude');
     $longitude = $request->input('longitude');
     $city = $request->input('city');
     $state = $request->input('state');
     $country = $request->input('country');
     $city = City::findOrCreate(compact('city', 'state', 'country'))->id;
     $point = new Spatialpoint();
     $point->point = Spatialpoint::geom($latitude, $longitude);
     $point->species = $request->input('species');
     $point->comments = $request->input('comments');
     $point->type = $request->input('type');
     $point->address = $request->input('address');
     $point->image = $image;
     $point->user_id = Auth::user()->id;
     $point->city_id = $city;
     $point->save();
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     DB::connection()->enableQueryLog();
     $data['location'] = GeoIP::getLocation();
     $l_city = $data['location']['city'];
     $l_state = $data['location']['state'];
     $agent = new Agent();
     $get_city = \App\City::where('city', '=', $l_city)->take(1)->get();
     if (count($get_city) != 0) {
         foreach ($get_city as $c) {
             $city = $c->id;
         }
     } else {
         $city = 894;
         $data['location']['city'] = 'Phoenix';
         $data['location']['state'] = 'AZ';
     }
     $data['recent_restaurants'] = \App\Restaurants::where('having_menu', '=', '1')->where('city_id', '=', $city)->orderBy(DB::raw('RAND()'))->take(4)->get();
     $data['recent_reviews'] = \App\Restaurant_Reviews::orderBy(DB::raw('RAND()'))->leftJoin('restaurants', 'restaurants_reviews.restaurants_id', '=', 'restaurants.id')->leftJoin('city', 'restaurants.city_id', '=', 'city.id')->leftJoin('state', 'restaurants.state_id', '=', 'state.id')->take(6)->get();
     //$data['nearest_zip'] = \App\Zip::where('zip', '>', (int)session('geoip-locations.postal_code')-10)->where('zip', '<', (int)session('geoip-locations.postal_code')+10)
     //  ->take(5)->get();
     //dd(DB::getQueryLog());
     //dd($data['recent_reviews']);
     if ($agent->isMobile()) {
         return view('mobile_home')->with($data);
     } else {
         return view('home')->with($data);
     }
 }
 public function slugs()
 {
     $slugs = Slug::orderBy('updated_at', 'desc')->get();
     /******************/
     $dirtyCities = Flight::doesntHave('city')->orderBy('country_code')->groupBy('city')->get();
     $cleanCities = City::groupBy('city_slug')->get();
     $noMatches = array();
     $dirtyCountries = array();
     $cleanCountries = array();
     foreach ($dirtyCities as $dirtyCity) {
         $similarsArray = array();
         foreach ($cleanCities as $cleanCity) {
             similar_text($dirtyCity->city_slug, $cleanCity->city_slug, $percent);
             $similarityArray[$cleanCity->city_slug] = $percent;
             $cleanCountries[$cleanCity->city_slug] = $cleanCity->country_code;
         }
         //sort in descending order
         arsort($similarityArray);
         //take first few with highest similarity
         $similarityArray = array_slice($similarityArray, 0, 8);
         $noMatches[$dirtyCity->city_slug] = $similarityArray;
         $dirtyCountries[$dirtyCity->city_slug] = $dirtyCity->country_code;
     }
     return view('scrapers.slugs')->with(['slugs' => $slugs, 'noMatches' => $noMatches, 'dirtyCountries' => $dirtyCountries, 'cleanCountries' => $cleanCountries]);
 }
Exemple #16
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $cities = City::all();
     // Grab all the cities and then do a for each.
     // run this for each of them.
     foreach ($cities as $city) {
         $events = Event::where('city_id', '=', $city->id)->where('time_end', '>=', date('Y-m-d H:i:s'))->where('time_end', '<=', date('Y-m-d H:i:s', strtotime('+2 weeks')))->orderBy('time_start', 'asc')->get();
         if (!count($events)) {
             $this->comment('No events found for ' . $city->name . '. Mailer not sent.');
             continue;
         }
         $categories = Category::orderBy('title', 'asc')->get();
         if ($this->option('email')) {
             $subscriber = new Subscriber();
             $subscriber->name = 'Test User';
             $subscriber->email = $this->option('email');
             $subscribers = [$subscriber];
             $this->comment('Sent test email to ' . $this->option('email'));
         } else {
             $subscribers = Subscriber::where('city_id', '=', $city->id)->get();
         }
         $count = 0;
         foreach ($subscribers as $subscriber) {
             Mail::send('emails.subscribers.mailer', ['subscriber' => $subscriber, 'events' => $events, 'categories' => $categories, 'city' => $city], function ($m) use($subscriber, $city) {
                 $m->from('*****@*****.**', 'See+Do')->to($subscriber->email, $subscriber->name)->subject('Weekly Round-Up of Things to See+Do in ' . $city->name)->getHeaders()->addTextHeader('X-MC-Subaccount', 'see-do');
             });
             $count++;
         }
         $this->comment('Sent to ' . $count . ' email addresses in ' . $city->name . '.');
         $count = 0;
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $city = City::findByIATA('nyc')->first();
     $event = Event::where('city_id', '=', $city->id);
     $city->delete();
     $event->delete();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     \App\City::create(['name' => 'Brisbane', 'country' => 'Australia', 'latitude' => -27.47101, 'longitude' => 153.02345]);
     // $this->call(UserTableSeeder::class);
     Model::reguard();
 }
 public function getSearch()
 {
     // get all the cities from cities table in alphabetical order
     $city = City::orderBy('name')->get();
     //make the insert view with cities
     return View::make('search')->with('cities', $city);
 }
Exemple #20
0
 /**
  * @param City $city
  * @param $thing
  * @param array $price
  * @param $time
  * @return $this|bool
  */
 public function levelUp($city, Model $thing, array $price, $time)
 {
     $lack_resource = $city->hasEnoughResources($price);
     if (empty($lack_resource)) {
         $thing->level += 1;
         $thing->finished_at = Carbon::now()->addSeconds($time);
         $city->resources->subtract($price);
         $thing->save();
     }
     $messages = [];
     $resources = ['stone' => 'kő', 'lumber' => 'fa', 'food' => 'élelmiszer', 'iron' => 'vas'];
     foreach ($lack_resource as $key => $value) {
         $messages["not_enough_{$key}"] = "Még {$value} {$resources[$key]} hiányzik";
     }
     return redirect()->back()->withErrors($messages);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $zone = Zone::findOrFail($id);
     $page = "Editer " . $zone->name;
     $cities = City::all();
     return view('admin.zone.edit', compact('zone', 'page', 'cities'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $country = Country::find($request->country_id);
     $city = City::find($request->city_id);
     $state = State::find($request->state_id);
     return ['country' => $country->name, 'city' => $city->name, 'state' => $state->name];
 }
Exemple #23
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $pages = Page::all();
     $cities = City::all();
     view()->share('pages', $pages);
     view()->share('cities', $cities);
 }
Exemple #24
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // If the user isn't logged in or they are part of a different city
     // deny access, otherwise go for it. Might be worth adding a message to
     // explain what happened on redirect.
     $city = City::findByIATA($request->route()->getParameter('city'))->first();
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             Notification::error('You need to be logged in to view that.');
             return redirect()->guest('auth/login');
         }
     } else {
         if ($city && $this->auth->user()->city_id !== $city->id) {
             Notification::error('You don\'t have permissions for that city.');
             if ($request->ajax()) {
                 return response('Unauthorized.', 401);
             } else {
                 return redirect('/' . $city->iata);
             }
         }
     }
     return $next($request);
 }
Exemple #25
0
 public function edit($id)
 {
     $cities = City::all();
     $categories = Category::all();
     $post = $this->postRepository->getById($id);
     return view('posts.edit', compact('post', 'cities', 'categories'));
 }
 public function getlist(Request $request)
 {
     $data = [];
     $data += ["" => '-- Selecciona ciudad --'];
     $data += City::where('state_id', $request->city_id)->lists('name', 'id')->toArray();
     return $data;
 }
 public function index()
 {
     $cities = City::all();
     //        $locations = Location::all();
     //        return view('worldmap.map')->with(compact('locations'));
     return view('worldmap.worldmap')->with(compact('cities'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('cities')->delete();
     for ($i = 0; $i < count($this->items); $i++) {
         $row = array_combine(['id', 'name'], $this->items[$i]);
         City::create($row);
     }
 }
 public function create()
 {
     $area = Area::lists('name', 'id');
     $typeOfProperty = TypeOfProperty::lists('type', 'id');
     $numberOfRooms = NumberOfRooms::lists('number', 'id');
     $city = City::lists('city', 'id');
     return view('announcements.create', compact('area', 'typeOfProperty', 'numberOfRooms', 'city'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //$countries = \App\Country::all()->lists('name','id');
     //$states = \App\State::all()->lists('name','id');
     $cities = \App\City::with('state')->get();
     return response()->json($cities);
     return view('states.index', ['cities' => $cities]);
 }