public function getlist(Request $request)
 {
     $data = [];
     $data += ["" => '-- Selecciona ciudad --'];
     $data += City::where('state_id', $request->city_id)->lists('name', 'id')->toArray();
     return $data;
 }
 /**
  * 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);
     }
 }
示例#3
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param array $data
  *
  * @return User
  */
 protected function create(array $data)
 {
     $token = Token::where('token', '=', $data['registration_token'])->first();
     $city = City::where('id', '=', $token->city_id)->first();
     $user = User::create(['name_first' => $data['name_first'], 'name_last' => $data['name_last'], 'username' => $data['username'], 'bio' => $data['bio'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'city_id' => $city->id]);
     Event::fire(new PostSuccessfullAuth($data['registration_token']));
     return $user;
 }
示例#4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($this->user) {
         $cities = City::all();
     } else {
         $cities = City::where('hidden', '!=', 1)->get();
     }
     return view('home.index', compact('cities'));
 }
示例#5
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;
 }
示例#6
0
 public static function city($id)
 {
     $id = unserialize($id);
     foreach ($id as $id) {
         $db_city = City::where('id', $id)->get();
         foreach ($db_city as $db) {
             echo $db->name . "<br>";
         }
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Get all the event records.
     $city = City::where('iata', '=', 'mcr')->first();
     $events = Event::get();
     // Get all the current events and attribute them to manchester (MCR).
     foreach ($events as $event) {
         $event->city_id = $city->id;
         $event->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Get all the user records.
     $city = City::where('iata', '=', 'mcr')->first();
     $users = User::get();
     // Get all the current users and associate them with manchester (MCR).
     foreach ($users as $user) {
         $user->city_id = $city->id;
         $user->save();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json_data = file_get_contents('custom/toronto_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'Toronto')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
     $json_data = file_get_contents('custom/nyc_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'New York City')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
     $json_data = file_get_contents('custom/paris_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'Paris')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
 }
示例#10
0
 public function city1_autocomplete(Request $request)
 {
     $data = City::where('PolpulatedPlace', 'LIKE', $request->term . '%')->take(20)->get();
     // dd($data);
     // $results = [];
     foreach ($data as $key => $value) {
         // $results[] = ['id'=>$value->ID, 'oblast'=>$value->Region, 'obshtina'=>$value->Municipality, 'text'=>$value->PolpulatedPlace];
         // dd($results);
         $results[$key]['id'] = $value->ID;
         $results[$key]['text'] = $value->PolpulatedPlace;
     }
     return response()->json($results);
     //return "{ \"results\": " . json_encode($city) . "}";
 }
示例#11
0
 private function tweet($event)
 {
     // Add check to see if the city has consumer secret/keys set, if not then add warning with url for city settings page.
     $city = City::where('id', '=', $event->city_id)->first();
     $title = $event->title;
     $date = date('d/m/y', strtotime($event->time_start));
     $time = date('g.ia', strtotime($event->time_start));
     $venue = explode(",", $event->venue)[0];
     $link = route('{city}.events.show', ['city' => $city->iata, 'slug' => $event->slug]);
     $status = $title . ' - ' . $date . ' - ' . $time . ' at ' . $venue . '. ' . $link;
     Twitter::reconfig(['consumer_key' => $city->twitter_consumer_key, 'consumer_secret' => $city->twitter_consumer_secret, 'token' => $city->twitter_access_token, 'secret' => $city->twitter_access_token_secret]);
     Twitter::postTweet(array('status' => $status, 'format' => 'json'));
     Log::info($status);
 }
示例#12
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = $request->path();
     if (Auth::user()) {
         $cities = City::all();
     } else {
         $cities = City::where('hidden', '!=', 1)->get();
     }
     if (count($cities) < 2 && $route == '/') {
         return redirect('/mcr');
     } else {
         return $next($request);
     }
 }
示例#13
0
 public function getTowns()
 {
     $input = \Request::all();
     $search = '%' . $input['term'] . '%';
     $cities = City::where('location', 'like', $search)->orderBy('location', 'asc')->take(10)->get()->lists('full_location', 'id');
     foreach ($cities as $key => $val) {
         $new_row['label'] = htmlentities(stripslashes($val));
         $new_row['value'] = htmlentities(stripslashes($val));
         $new_row['id'] = $key;
         $row_set[] = $new_row;
         //build an array
     }
     return $row_set;
 }
示例#14
0
文件: User.php 项目: vizovteam/vizov
 public static function detectUserLocation()
 {
     $city = [NULL];
     if (auth()->check()) {
         $user = auth()->user();
         // $city = $user->profile->city()->get();
     } else {
         $user_location = GeoIP::getLocation();
         $city = City::where('slug', $user_location['city'])->get();
     }
     if (empty($city[0])) {
         $city[0] = City::first();
     }
     view()->share('user_city', $city[0]);
 }
示例#15
0
 public function addFoodToArmy(Request $request, $city_id)
 {
     $city = City::where('id', $city_id)->first();
     if (!$this->validateOwner($city)) {
         return redirect('/home')->withErrors('Nem a te városod');
     }
     $food = $request->input("army_food");
     if (!$city->resources->food >= $food) {
         return redirect("/city/{$city_id}")->withErrors('Nincs elég élelmiszer');
     }
     $army = $city->army();
     $army->food += $food;
     $army->save();
     $city->resources->food -= $food;
     $city->resources->save();
     return redirect("/city/{$city_id}");
 }
示例#16
0
 public function filter(Request $request)
 {
     $allCommunities = $request->communities;
     $communities = Community::where('city_id', $request->city)->get();
     $requestedInfo = $request;
     if ($request->from == '' || $request->from == 0) {
         $from = 1.0E+17;
     } else {
         $from = $request->from;
     }
     if (sizeof($allCommunities) > 0) {
         $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->whereIn('community_id', $allCommunities)->where('city_id', $request->city)->paginate(12);
     } else {
         $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->where('city_id', $request->city)->paginate(12);
     }
     $city = City::where('id', $request->city)->get();
     return view('city.home', ['posts' => $posts, 'city' => $city, 'communities' => $communities, 'request' => $requestedInfo]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $cities = [];
     $cities[] = City::where('geoname_id', 658225)->first();
     $cities[] = City::where('geoname_id', 649360)->first();
     $cities[] = City::where('geoname_id', 660158)->first();
     $cities[] = City::where('geoname_id', 632453)->first();
     $cities[] = City::where('geoname_id', 634963)->first();
     $images = Image::all();
     $users = User::all();
     for ($i = 0; $i < 100; $i++) {
         $city = $cities[rand(0, count($cities) - 1)];
         $image = $images[rand(0, count($images) - 1)];
         $logo_image = $images[rand(0, count($images) - 1)];
         $user = $users[rand(0, count($users) - 1)];
         $id = DB::table('designer')->insertGetId(['city_id' => $city->id, 'image_id' => $image->id, 'logo_id' => $logo_image->id, 'user_id' => $user->id, 'email' => '*****@*****.**', 'website' => 'http://www.example.com/', 'facebook' => 'https://www.facebook.com/', 'twitter' => 'https://twitter.com/', 'google_plus' => 'https://plus.google.com/', 'instagram' => 'https://www.instagram.com/', 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s')]);
         DB::table('designer_translation')->insert(['designer_id' => $id, 'locale' => 'en', 'name' => 'Test Designer ' . $id, 'tagline' => 'Good typeface make any text easier to read', 'content' => file_get_contents('http://loripsum.net/api'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s')]);
     }
 }
示例#18
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('user', function ($value) {
         return \App\User::whereSlug($value)->firstOrFail();
     });
     $router->bind('category', function ($value) {
         return \App\Category::whereSlug($value)->firstOrFail();
     });
     $router->bind('event', function ($value) {
         return \App\Event::whereSlug($value)->firstOrFail();
     });
     $router->bind('city', function ($value) {
         return \App\City::where('iata', $value)->firstOrFail();
     });
     $router->bind('subscriber', function ($value) {
         return \App\Subscriber::where('token', $value)->firstOrFail();
     });
     parent::boot($router);
 }
示例#19
0
 public function parse(Request $request)
 {
     $parsed = json_decode($request['json'], true);
     foreach ($parsed as $key => $value) {
         unset($parsed[$key]['images']);
         unset($parsed[$key]['href']);
         $city = City::where('name', $value['city_id'])->first();
         if ($city === null) {
             unset($parsed[$key]);
             continue;
         }
         $parsed[$key]['category_id'] = 5;
         $parsed[$key]['city_id'] = $city->id;
         $parsed[$key]['created_at'] = Carbon::now()->subMinutes(rand(1, 59));
         $parsed[$key]['updated_at'] = Carbon::now()->subMinutes(rand(1, 59));
     }
     // dd($parsed);
     Ad::insert($parsed);
     return response('OK', 200);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $cities = [];
     $cities[] = City::where('geoname_id', 658225)->first();
     $cities[] = City::where('geoname_id', 649360)->first();
     $cities[] = City::where('geoname_id', 660158)->first();
     $cities[] = City::where('geoname_id', 632453)->first();
     $cities[] = City::where('geoname_id', 634963)->first();
     $images = Image::all();
     $users = User::all();
     $types = Place::types();
     for ($i = 0; $i < 100; $i++) {
         $city = $cities[rand(0, count($cities) - 1)];
         $image = $images[$i % count($images)];
         $user = $users[rand(0, count($users) - 1)];
         $type = $types[rand(0, count($types) - 1)];
         $id = DB::table('place')->insertGetId(['city_id' => $city->id, 'image_id' => $image->id, 'user_id' => $user->id, 'type' => $type, 'address' => 'Servinkuja 1 B 19', 'latitude' => $city->latitude + rand(0, 1000) / 20000 - 0.025, 'longitude' => $city->longitude + rand(0, 1000) / 20000 - 0.025, 'phone' => '+3581234567', 'email' => '*****@*****.**', 'website' => 'http://www.example.com/', 'facebook' => 'https://www.facebook.com/', 'google_plus' => 'https://plus.google.com/', 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s')]);
         DB::table('place_translation')->insert(['place_id' => $id, 'locale' => 'en', 'name' => 'Test ' . $type . ' ' . $id, 'content' => file_get_contents('http://loripsum.net/api'), 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s')]);
     }
 }
示例#21
0
 public function search(Request $request)
 {
     $data = array();
     $data['days'] = \App\Day::lists('name', 'id');
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['city'] = \App\City::all();
     $data['specialization'] = \App\Specialization::all();
     $data['city_k'] = urldecode($request->input('city'));
     $data['specialization_k'] = urldecode($request->input('specialization'));
     $data['keyword'] = urldecode($request->input('keyword'));
     $data['gender_k'] = $request->input('gender');
     $data['practice_day_k'] = $request->input('practice_day');
     $data['city_obj'] = \App\City::where('name', 'like', '%' . $data['city_k'] . '%')->lists('id');
     $arr_specialization = \App\Specialization::where('name', 'like', '%' . $data['specialization_k'] . '%')->lists('id');
     /*$result = \App\Specialization::where('name','like','%'.$data['specialization_k'].'%')
       ->whereHas('doctors', function($query) use($data){
           $query->whereIn('city_id', $data['city_obj'])
               ->where('name','like', '%'.$data['keyword'].'%')
               ->whereHas('day', function($query) use($data){
                 if(!empty($data['practice_day_k']) > 0)
                   $query->whereIn('days.id', $data['practice_day_k']);
               })
           ;
           if(!empty($data['gender_k'])){
             $query->where('gender',$data['gender_k']);
           }
       })->
       with('doctors')->get();*/
     $result = \App\Doctor::whereIn('city_id', $data['city_obj'])->where('name', 'like', '%' . $data['keyword'] . '%')->whereHas('day', function ($query) use($data) {
         if (!empty($data['practice_day_k']) > 0) {
             $query->whereIn('days.id', $data['practice_day_k']);
         }
     });
     if (!empty($data['gender_k'])) {
         $result->where('gender', $data['gender_k']);
     }
     $result = $result->paginate(10);
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['content'] = $result;
     return view('frontend.pages.home.search-result', compact('data'));
 }
示例#22
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $this->validate($request, ['city_id' => 'integer|exists:city,id', 'tag_id' => 'integer|exists:tag,id', 'type' => 'string|in:' . implode(',', Place::types())]);
     if ($request->has('city_id')) {
         $city = City::find($request->input('city_id'));
     } else {
         $city = City::where('geoname_id', 658225)->first();
         if (!count($city)) {
             $city = City::first();
         }
     }
     $query = Place::where('city_id', $city->id);
     if ($request->has('search')) {
         $words = explode(" ", $request->input('search'));
         $query->whereHas('translations', function ($sub_query) use($words) {
             foreach ($words as $word) {
                 // If it is Chinese, use LIKE. Else, use full text index.
                 // http://www.regular-expressions.info/unicode.html#script
                 if (preg_match('/\\p{Han}+/u', $word)) {
                     $sub_query->where(function ($q) use($word) {
                         $q->where('name', 'like', '%' . $word . '%')->orWhere('content', 'like', '%' . $word . '%');
                     });
                 } else {
                     $sub_query->whereRaw('MATCH(name,content) AGAINST(? IN BOOLEAN MODE)', [$word . '*']);
                 }
             }
         });
     }
     if ($request->has('type')) {
         $query = $query->where('type', $request->input('type'));
     }
     if ($request->has('tag_id')) {
         $query = $query->whereHas('tags', function ($sub_query) use($request) {
             $sub_query->where('id', $request->input('tag_id'));
         });
     }
     $query->with('image');
     $places = $query->orderBy('like_count', 'desc')->paginate(24);
     return view('pages.place.index', ['places' => $places, 'city' => $city, 'type' => $request->input('type')]);
 }
示例#23
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $this->validate($request, ['search' => 'string|max:20', 'country_id' => 'integer|exists:country,id']);
     if ($request->has('search') && $request->has('country_id')) {
         $search = $request->input('search');
         $cities = City::whereHas('translations', function ($query) use($search) {
             $query->where('name', 'like', $search . '%');
         })->where('country_id', $request->input('country_id'))->paginate(15);
     } elseif ($request->has('search')) {
         $search = $request->input('search');
         $cities = City::whereHas('translations', function ($query) use($search) {
             $query->where('name', 'like', $search . '%');
         })->paginate(15);
     } elseif ($request->has('country_id')) {
         $cities = City::where('country_id', $request->input('country_id'))->paginate(15);
     } else {
         $cities = City::paginate(15);
     }
     if ($request->wantsJSON()) {
         return response()->json($cities->toArray(), 200);
     } else {
         return view('pages.city.index', ['cities' => $cities]);
     }
 }
示例#24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($community, $id)
 {
     $post = Post::with('author', 'comments.author', 'community')->where('id', $id)->get();
     $comments = Comment::with('author')->where('post_id', $id)->get();
     $community = Community::where("id", $community)->get();
     $city = City::where('id', $post[0]->city_id)->get();
     return view('posts.show', ['post' => $post, "comments" => $comments, 'community' => $community, 'city' => $city]);
 }
 public function index()
 {
     $cities = City::where('state_id', '=', Input::get('state_id'))->orderBy('name')->get();
     return response()->json($cities);
 }
示例#26
0
 public function parseAndSave($html, $hhId, $link = null)
 {
     if (!$html) {
         return 'Parse error';
     }
     $vacancy = new Vacancy();
     if ($vacancy->where('hh_id', '=', $hhId)->first()) {
         return 'Vacancy ' . $hhId . ' found in database';
     }
     //name
     if ($obj = $html->find('.b-vacancy-title', 0)) {
         $title = $obj->plaintext;
     }
     //description
     if ($obj = $html->find('.b-vacancy-desc-wrapper', 0)) {
         $description = $obj->innertext;
     }
     //address
     if ($obj = $html->find('.vacancy-address-text', 0)) {
         $address = $obj->innertext;
     }
     //company_name
     if ($obj = $html->find('.companyname', 0)) {
         $companyName = $obj->plaintext;
     }
     //employmentMode
     $employmentMode = array();
     foreach ($html->find('.b-vacancy-employmentmode span') as $span) {
         $employmentMode[] = $span->innertext;
     }
     $head = $html->find('.b-vacancy-info .l-content-3colums', 0)->innertext;
     if ($res = $html->str_get_html($head)) {
         //content
         if ($obj = $res->find('.l-content-colum-1', 1)) {
             if ($tag = $obj->find('.l-paddings meta', 0)) {
                 $currency = $tag->content;
             }
         }
         //salary
         if ($obj = $res->find('.l-content-colum-1', 1)) {
             if ($tag = $obj->find('.l-paddings', 0)) {
                 $salaryText = $tag->plaintext;
             }
         }
         if (!empty($salaryText)) {
             if (!preg_match('/[\\d]{1}/i', $salaryText)) {
                 $salary_from = 0;
                 $salary_to = 0;
             } else {
                 $salary = explode('до', $salaryText);
                 if (isset($salary[0]) && strlen(trim($salary[0])) > 0) {
                     preg_match_all('/[\\w]{2}(.*)[\\w\\s\\.]{1,4}/', $salary[0], $matches);
                     $str = str_replace(chr(194) . chr(160), '', $matches[0][0]);
                     $str = str_replace(' ', '', $str);
                     $salary_from = intval($str);
                 }
                 if (isset($salary[1]) && strlen(trim($salary[1])) > 0) {
                     preg_match_all('/[\\w\\s]{1,2}(.*)[\\w\\s]{1,3}/', $salary[1], $matches);
                     $str = str_replace(chr(194) . chr(160), '', $matches[0][0]);
                     $str = str_replace(' ', '', $str);
                     $salary_to = intval($str);
                 }
             }
         }
         //cityName
         if ($obj = $res->find('.l-content-colum-2', 1)) {
             if ($tag = $obj->find('.l-paddings', 0)) {
                 $cityName = $tag->plaintext;
             }
         }
         //metro
         if ($obj = $res->find('.l-content-colum-2', 1)) {
             if ($tag = $obj->find('.metro-station', 0)) {
                 $metro = $tag->plaintext;
             }
         }
         if (isset($metro)) {
             $cityName = str_replace(',', '', $cityName);
             $cityName = str_replace(',', '', $metro);
             $cityName = trim($cityName);
         }
         //experience
         if ($obj = $res->find('.l-content-colum-3', 1)) {
             if ($tag = $obj->find('.l-paddings', 0)) {
                 $experience = $tag->plaintext;
             }
         }
     }
     // Save Vacancy
     $vacancy = new Vacancy();
     if (isset($title)) {
         $vacancy->name = $title;
     }
     if (isset($companyName)) {
         $vacancy->company_name = $companyName;
     }
     if (isset($hhId)) {
         $vacancy->hh_id = $hhId;
     }
     if (isset($link)) {
         $vacancy->hh_link = $link;
     }
     if (isset($salary_from)) {
         $vacancy->salary_from = $salary_from;
     }
     if (isset($salary_to)) {
         $vacancy->salary_to = $salary_to;
     }
     if (isset($currency)) {
         $vacancy->currency = $currency;
     }
     if (isset($cityName)) {
         $cities = new City();
         if ($city = $cities->where('name', '=', $cityName)->first()) {
             $vacancy->city_id = $city->id;
         } else {
             // save new city
             $city = new City();
             $city->name = $cityName;
             $city->save();
             $vacancy->city_id = $city->id;
         }
     }
     if (isset($experience)) {
         $vacancy->experience = $experience;
     }
     if (isset($description)) {
         $vacancy->description = $description;
     }
     if (isset($address)) {
         $vacancy->address = $address;
     }
     // save
     if (!$vacancy->save()) {
         return 'Vacancy not saved';
     }
     // Employment Types Save
     if (count($employmentMode) > 0) {
         $empType = new \App\EmploymentType();
         foreach ($employmentMode as $emp) {
             if ($find = $empType->where('name', 'LIKE', '%' . $emp . '%')->first()) {
                 $empIds[] = $find->id;
             } else {
                 // save new EmploymentType
                 $employ = new EmploymentType();
                 $employ->name = $emp;
                 $employ->save();
                 $empIds[] = $employ->id;
             }
         }
         $empType = new \App\EmploymentType();
         $vacancy->employmentTypes()->attach($empIds);
     }
     return true;
 }
示例#27
0
 /**
  * Remove a City from storage
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroyCity($id)
 {
     City::where('id', $id)->delete();
     Session::flash('success_message', 'City has been deleted from database');
     return redirect('config');
 }
示例#28
0
     $property = Property::find($property_id);
     $images = get_all_images_from_property_id_without_placeholder($property_id);
     return view('edit_images', ['property' => $property, 'images' => $images]);
 });
 Route::post('/property/edit', function (Request $request) {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['title' => 'required|max:255', 'city' => 'required', 'district' => 'required', 'address' => 'required|max:255', 'type' => 'required|in:private_room,shared_room,entire_place', 'max_occupancy' => 'required|numeric|min:0|integer', 'price_per_night' => 'required|numeric|min:0|max:9999.99', 'description' => 'required', 'property_id' => 'required|numeric|integer|min:0']);
     if ($validator->fails()) {
         return redirect(url('/property/edit/' . $data['property_id']))->withInput()->withErrors($validator);
     }
     $myErrorArr = array();
     $districts = District::where('name', $request->district)->get();
     if (count($districts) < 1) {
         array_push($myErrorArr, 'That district is not recognized');
     }
     $cities = City::where('name', $request->city)->get();
     if (count($cities) < 1) {
         array_push($myErrorArr, 'That city is not recognized.');
     }
     if (count($myErrorArr) > 0) {
         return redirect(url('/property/add'))->withInput()->withErrors($myErrorArr);
     }
     $property = Property::find($data['property_id']);
     $property->title = $request->title;
     $property->address = $request->address;
     $property->district_id = $districts[0]->id;
     $property->city_id = $cities[0]->id;
     $property->type = $request->type;
     $property->price_per_night = $request->price_per_night;
     $property->max_occupancy = $request->max_occupancy;
     $property->description = $request->description;
示例#29
0
文件: City.php 项目: Dimimo/Booklet
 /**
  * return the city->id of an autocomplete search
  *
  * @param $city
  *
  * @return false|Model
  */
 public static function getCityFromAutoComplete($city)
 {
     preg_match('/\\((.*?)\\)/', $city, $province);
     if (!isset($province[1])) {
         return false;
     }
     $province = Province::whereSlug(str_slug($province[1]))->first();
     $city = preg_split('/\\(([\\s]*)/', $city);
     if (!isset($city[0])) {
         return false;
     }
     $city = City::where(['slug' => str_slug($city[0]), 'province_id' => $province->id])->first();
     if ($city) {
         return $city->id;
     }
     return false;
 }
示例#30
0
 public function getCityData(Request $request)
 {
     TaskController::checkTasks();
     return City::where('id', $request->input('city'))->first()->toJson();
 }