/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $allusers = User::all();
     $url = "https://randomapi.com/api/?key=" . env('RANDOMAPI_API_KEY') . "&id=6tnf0qn&results=50";
     $json = file_get_contents($url);
     $json_data = json_decode($json, true);
     $types = ['private_room', 'shared_room', 'entire_place'];
     foreach ($json_data['results'] as $result) {
         $result = $result['object'];
         $property = new Property();
         $property->title = $result['title'];
         $oneuser = $allusers[rand(0, count($allusers) - 1)];
         $property->owner_id = $oneuser->id;
         $property->address = explode(" | ", $result['address'])[2];
         $all_cities = City::all();
         $property->city_id = $all_cities[rand(0, count($all_cities) - 1)]->id;
         $valid_districts = District::where('city_id', $property->city_id)->get();
         $property->district_id = $valid_districts[rand(0, count($valid_districts) - 1)]->id;
         $property->type = $types[array_rand($types)];
         $property->price_per_night = rand(20, 1333);
         $property->max_occupancy = rand(1, 6);
         $property->description = 'A charming ' . $result['title'];
         $property->save();
         $features = new PropertyFeatures();
         $features->property_id = $property->id;
         $features->kitchen = rand(0, 1) == 1;
         $features->internet = rand(0, 1) == 1;
         $features->tv = rand(0, 1) == 1;
         $features->essentials = rand(0, 1) == 1;
         $features->shampoo = rand(0, 1) == 1;
         $features->heating = rand(0, 1) == 1;
         $features->air_conditioning = rand(0, 1) == 1;
         $features->washer = rand(0, 1) == 1;
         $features->dryer = rand(0, 1) == 1;
         $features->free_parking_on_premises = rand(0, 1) == 1;
         $features->wireless_internet = rand(0, 1) == 1;
         $features->cable_tv = rand(0, 1) == 1;
         $features->breakfast = rand(0, 1) == 1;
         $features->pets_allowed = rand(0, 1) == 1;
         $features->family_kid_friendly = rand(0, 1) == 1;
         $features->suitable_for_events = rand(0, 1) == 1;
         $features->smoking_allowed = rand(0, 1) == 1;
         $features->wheelchair_accessible = rand(0, 1) == 1;
         $features->elevator_in_building = rand(0, 1) == 1;
         $features->indoor_fireplace = rand(0, 1) == 1;
         $features->buzzer_wireless_intercom = rand(0, 1) == 1;
         $features->doorman = rand(0, 1) == 1;
         $features->pool = rand(0, 1) == 1;
         $features->hot_tub = rand(0, 1) == 1;
         $features->gym = rand(0, 1) == 1;
         $features->feature_24_hour_check_in = rand(0, 1) == 1;
         $features->hangers = rand(0, 1) == 1;
         $features->iron = rand(0, 1) == 1;
         $features->hair_dryer = rand(0, 1) == 1;
         $features->laptop_friendly_workspace = rand(0, 1) == 1;
         $features->save();
     }
 }
 public function showFromID($id)
 {
     $districts = District::where('province_id', $id)->get();
     foreach ($districts as $reg) {
         $prov = Province::where('region_id', $reg->id)->orderBy('name')->get();
         array_push($provinces, $prov);
     }
     dd($id);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(DistrictRequest $request)
 {
     $district = District::where('id', $request['districtID'])->first();
     $district->name = $request['name'];
     $district->updated_by = \Auth::user()->id;
     $district->save();
     \Session::flash('success', 'well done! District ' . $request['name'] . ' has been successfully added!');
     return redirect()->back();
 }
 /**
  * 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();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // QUẬN 1
     $wards_quan1 = ['Bến Nghé', 'Bến Thành', 'Cầu Kho', 'Cầu Ông Lãnh', 'Cô Giang', 'Đa Kao', 'Nguyễn Cư Trinh', 'Nguyễn Thái Bình', 'Phạm Ngũ Lão', 'Tân Định'];
     $quan1 = District::where('key', 'quan-1')->get();
     $quan1_id = 1;
     $quan1_name = 'Quận 1';
     if (is_null($quan1) || $quan1->count() == 0) {
         $quan1_id = $quan1_id[0]->id;
         $quan1_name = $quan1_id[0]->name;
     }
     foreach ($wards_quan1 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan1_name), 'name' => $value, 'district_id' => $quan1_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan1_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan1_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan1_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan1_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan1_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan1_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN 2
     $wards_quan2 = ['An Khánh', 'An Lợi Đông', 'An Phú', 'Bình An', 'Bình Khánh', 'Bình Trưng Tây', 'Bình Trưng Đông', 'Cát Lái', 'Thạnh Mỹ Lợi', 'Thảo Điền', 'Thủ Thiêm'];
     $quan2 = District::where('key', 'quan-2')->get();
     $quan2_id = 2;
     $quan2_name = 'Quận 2';
     if (is_null($quan2) || $quan2->count() == 0) {
         $quan2_id = $quan2_id[0]->id;
         $quan2_name = $quan2_id[0]->name;
     }
     foreach ($wards_quan2 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan2_name), 'name' => $value, 'district_id' => $quan2_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan2_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan2_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN 9
     $wards_quan9 = ['Hiệp Phú', 'Long Bình', 'Long Phước', 'Long Thạnh Mỹ', 'Long Trường', 'Phú Hữu', 'Phước Bình', 'Phước Long A', 'Phước Long B', 'Tân Phú', 'Tăng Nhơn Phú A', 'Tăng Nhơn Phú B', 'Trường Thạnh'];
     $quan9 = District::where('key', 'quan-9')->get();
     $quan9_id = 9;
     $quan9_name = 'Quận 9';
     if (is_null($quan9) || $quan9->count() == 0) {
         $quan9_id = $quan9_id[0]->id;
         $quan9_name = $quan9_id[0]->name;
     }
     foreach ($wards_quan9 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan9_name), 'name' => $value, 'district_id' => $quan9_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan9_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan9_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan9_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan9_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan9_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan9_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN Thủ Đức
     $wards_quan_thu_duc = ['Bình Chiểu', 'Bình Thọ', 'Hiệp Bình Chánh', 'Hiệp Bình Phước', 'Linh Chiểu', 'Linh Đông', 'Linh Tây', 'Linh Trung', 'Linh Xuân', 'Tam Bình', 'Tam Phú', 'Trường Thọ'];
     $quan_thu_duc = District::where('key', 'quan-thu-duc')->get();
     $quan_thu_duc_id = 10;
     $quan_thu_duc_name = 'Quận Thủ Đức';
     if (is_null($quan_thu_duc) || $quan_thu_duc->count() == 0) {
         $quan_thu_duc_id = $quan_thu_duc_id[0]->id;
         $quan_thu_duc_name = $quan_thu_duc_id[0]->name;
     }
     foreach ($wards_quan_thu_duc as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan_thu_duc_name), 'name' => $value, 'district_id' => $quan_thu_duc_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan_thu_duc_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan_thu_duc_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // $streets_quan2 = ['1', '10', '10F', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '21A', '22', '23', '24', '25', '26', '27', '28', '29', '3', '30', '30B', '31', '31A', '31B', '31C', '31D', '31E', '31F', '32', '33', '34', '35', '36', '37A', '38', '39', '4', '40', '41', '41B', '42', '43', '44', '45', '46', '47', '49', '5', '50', '51', '52', '53', '54', '55', '56', '58', '59', '6', '60', '61', '62', '63', '64', '65', '66', '68', '7', '7A', '7C', '8', '80', '83', '8A', '8G', '8K', '9', '95', 'A2', 'An Phú', 'An Phú Đông 27', 'An Trang', 'B', 'Bát Nàn', 'Bình An', 'Bình Trưng', 'Bùi Tá Hán', 'Cao Đức Lân', 'Đại Lộ Đông Tây', 'Đàm Văn Lễ', 'Đặng Hữu Phổ', 'Đặng Như Mai', 'Đặng Tiến Đông', 'Đỗ Pháp Thuận', 'Đỗ Quang', 'Đỗ Xuân Hợp', 'Đoàn Hữu Trưng', 'Đông Hưng Thuận 6', 'Đồng Quốc Bình', 'Đồng Văn Cống', 'Dư Hàng Kênh', 'Đường A', 'Đường C', 'Dương Văn An', 'G1', 'Giang Văn Minh', 'H', 'Hà Quang', 'Hàn Giang', 'Hậu Lân', 'Hiệp Thành 13', 'Hương lộ 62', 'K', 'KP3', 'Lâm Quang Ký', 'Lê Đình Quản', 'Lê Đức Thọ', 'Lê Hiến Mai', 'Lê Hồng Phong', 'Lê Hữu Kiều', 'Lê Phụng Hiểu', 'Lê Thước', 'Lê Văn Miến', 'Lê Văn Thịnh', 'Lộc Hòa', 'Lương Định Của', 'Lý Ông Trọng', 'Mai Chí Thọ', 'Mương Khai', 'Ngô Quang Huy', 'Nguyễn Án', 'Nguyễn Bá Huân', 'Nguyễn Bá Lân', 'Nguyễn Cừ', 'Nguyễn Đăng Đạo', 'Nguyễn Đăng Giai', 'Nguyễn Địa Lô', 'Nguyễn Đôn Tiết', 'Nguyễn Duy Hiệu', 'Nguyễn Duy Trinh', 'Nguyễn Hoàng', 'Nguyễn Hương', 'Nguyễn Huy Chương', 'Nguyễn Khanh', 'Nguyễn Khoa Đăng', 'Nguyễn Lương Dĩ', 'Nguyễn Quang Bật', 'Nguyễn Quý Cảnh', 'Nguyễn Quý Đức', 'Nguyễn Thanh Sơn', 'Nguyễn Thị Định', 'Nguyễn Trọng Quân', 'Nguyễn Trung Nguyệt', 'Nguyễn Tư Nghiêm', 'Nguyễn Tuyển', 'Nguyễn Ư Dĩ', 'Nguyễn Văn Giáp', 'Nguyễn Văn Hưởng', 'Nguyễn Văn Kỉnh', 'Phạm Công Trứ', 'Phạm Đôn Lễ', 'Phạm Hy Lượng', 'Phạm Thận Duật', 'Phan Bá Vành', 'Phan Văn Đáng', 'Quách Giai', 'Quốc Hương', 'Quốc lộ 1A', 'Song Hành', 'Sử Hy Nhan', 'Tạ Hiện', 'Tân Chánh Hiệp 16', 'Tân Lập 2', 'Tân Thới Hiệp 10', 'Thái Thuận', 'Thân Văn Nhiếp', 'Thạnh Lộc 27', 'Thạnh Mỹ Bắc', 'Thạnh Mỹ Lợi', 'Thạnh Mỹ Nam', 'Thạnh Xuân 13', 'Thạnh Xuân 21', 'Thảo Điền', 'Thích Mật Thể', 'Tỉnh Lộ 10', 'Tỉnh lộ 25B', 'Tống Hữu Định', 'Trại Gà', 'Trần Lưu', 'Trần Lựu', 'Trần Não', 'Trần Ngọc Diện', 'Trần Quang Đạo', 'Trích Sài', 'Trịnh Khắc Lập', 'Trúc Đường', 'Trương Gia Mô', 'Trương Văn Bang', 'Trương Văn Đa', 'Vạn Kiếp', 'Vành Đai 2', 'Vành Đai Đông', 'Võ Trường Toản', 'Võ Văn Kiệt', 'Vũ Phương Đế', 'Vũ Tông Phan', 'Xa Lộ Hà Nội', 'Xuân Thủy'];
     $streets_quan2 = ['An Phú', 'An Phú Đông 27', 'An Trang', 'B', 'Bát Nàn', 'Bình An', 'Bình Trưng', 'Bùi Tá Hán', 'Cao Đức Lân', 'Đại Lộ Đông Tây', 'Đàm Văn Lễ', 'Đặng Hữu Phổ', 'Đặng Như Mai', 'Đặng Tiến Đông', 'Đỗ Pháp Thuận', 'Đỗ Quang', 'Đỗ Xuân Hợp', 'Đoàn Hữu Trưng', 'Đông Hưng Thuận 6', 'Đồng Quốc Bình', 'Đồng Văn Cống', 'Dư Hàng Kênh', 'Đường A', 'Đường C', 'Dương Văn An', 'G1', 'Giang Văn Minh', 'H', 'Hà Quang', 'Hàn Giang', 'Hậu Lân', 'Hiệp Thành 13', 'Hương lộ 62', 'K', 'KP3', 'Lâm Quang Ký', 'Lê Đình Quản', 'Lê Đức Thọ', 'Lê Hiến Mai', 'Lê Hồng Phong', 'Lê Hữu Kiều', 'Lê Phụng Hiểu', 'Lê Thước', 'Lê Văn Miến', 'Lê Văn Thịnh', 'Lộc Hòa', 'Lương Định Của', 'Lý Ông Trọng', 'Mai Chí Thọ', 'Mương Khai', 'Ngô Quang Huy', 'Nguyễn Án', 'Nguyễn Bá Huân', 'Nguyễn Bá Lân', 'Nguyễn Cừ', 'Nguyễn Đăng Đạo', 'Nguyễn Đăng Giai', 'Nguyễn Địa Lô', 'Nguyễn Đôn Tiết', 'Nguyễn Duy Hiệu', 'Nguyễn Duy Trinh', 'Nguyễn Hoàng', 'Nguyễn Hương', 'Nguyễn Huy Chương', 'Nguyễn Khanh', 'Nguyễn Khoa Đăng', 'Nguyễn Lương Dĩ', 'Nguyễn Quang Bật', 'Nguyễn Quý Cảnh', 'Nguyễn Quý Đức', 'Nguyễn Thanh Sơn', 'Nguyễn Thị Định', 'Nguyễn Trọng Quân', 'Nguyễn Trung Nguyệt', 'Nguyễn Tư Nghiêm', 'Nguyễn Tuyển', 'Nguyễn Ư Dĩ', 'Nguyễn Văn Giáp', 'Nguyễn Văn Hưởng', 'Nguyễn Văn Kỉnh', 'Phạm Công Trứ', 'Phạm Đôn Lễ', 'Phạm Hy Lượng', 'Phạm Thận Duật', 'Phan Bá Vành', 'Phan Văn Đáng', 'Quách Giai', 'Quốc Hương', 'Quốc lộ 1A', 'Song Hành', 'Sử Hy Nhan', 'Tạ Hiện', 'Tân Chánh Hiệp 16', 'Tân Lập 2', 'Tân Thới Hiệp 10', 'Thái Thuận', 'Thân Văn Nhiếp', 'Thạnh Lộc 27', 'Thạnh Mỹ Bắc', 'Thạnh Mỹ Lợi', 'Thạnh Mỹ Nam', 'Thạnh Xuân 13', 'Thạnh Xuân 21', 'Thảo Điền', 'Thích Mật Thể', 'Tỉnh Lộ 10', 'Tỉnh lộ 25B', 'Tống Hữu Định', 'Trại Gà', 'Trần Lưu', 'Trần Lựu', 'Trần Não', 'Trần Ngọc Diện', 'Trần Quang Đạo', 'Trích Sài', 'Trịnh Khắc Lập', 'Trúc Đường', 'Trương Gia Mô', 'Trương Văn Bang', 'Trương Văn Đa', 'Vạn Kiếp', 'Vành Đai 2', 'Vành Đai Đông', 'Võ Trường Toản', 'Võ Văn Kiệt', 'Vũ Phương Đế', 'Vũ Tông Phan', 'Xa Lộ Hà Nội', 'Xuân Thủy'];
     $quan2 = District::where('key', 'quan-2')->get();
     $quan2_id = 2;
     $quan2_name = 'Quận 2';
     if (is_null($quan2) || $quan2->count() == 0) {
         $quan2_id = $quan2_id[0]->id;
         $quan2_name = $quan2_id[0]->name;
     }
     foreach ($streets_quan2 as $key => $value) {
         $street = Street::create(['key' => Common::createKeyURL($value . ' ' . $quan2_name), 'name' => $value, 'district_id' => $quan2_id, 'meta_description' => 'Bán căn hộ đường phố ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ đường phố ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ đường phố ' . $value . ' ' . $quan2_name, 'meta_keywords' => 'Bán căn hộ đường phố ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ đường phố ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ đường phố ' . $value . ' ' . $quan2_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 public function district(Request $request)
 {
     $district_id = $request->input('district');
     $districts = District::where('id', '=', $district_id)->get();
     $sectors = Sector::where('district_id', "=", $district_id)->get();
     foreach ($sectors as $sector) {
         $sectors_ids[] = $sector->id;
     }
     $cells = Cell::whereIn('sector_id', $sectors_ids)->get();
     foreach ($cells as $cell) {
         $cells_ids[] = $cell->id;
     }
     $markets = Market::whereIn('cell_id', $cells_ids)->get();
     foreach ($markets as $market) {
         $markets_ids[] = $market->id;
     }
     $prices = Price::whereIn('market_id', $markets_ids)->get();
     return view('reports.district')->with('districts', $districts)->with('sectors', $sectors)->with('prices', $prices);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(UserRequest $request, User $user)
 {
     /*  New User Table */
     $user->name = $request['Fname'];
     $user->surname = $request['Sname'];
     $user->cellphone = $request['Cell1'];
     $user->username = $request['Email'];
     $user->email = $request['Cell1'];
     $position = Position::where('slug', '=', $request['Position'])->first();
     $user->position = $position->id;
     $province = Province::where('slug', '=', $request['Province'])->first();
     $user->province = $province->id;
     $district = District::where('slug', '=', $request['District'])->first();
     $user->district = $district->id;
     $municipalityIds = array();
     foreach ($request['Municipality'] as $municipalityName) {
         $municipality = Municipality::where('slug', '=', $municipalityName)->first();
         $municipalityIds[] = $municipality->id;
     }
     $user->municipality = implode(",", $municipalityIds);
     $department = Department::where('slug', '=', $request['Department'])->first();
     $user->department = $department->id;
     $password = rand(1000, 99999);
     $user->password = \Hash::make($password);
     $user->api_key = uniqid();
     $user->status = 1;
     $user->role = 2;
     $user->save();
     \Session::flash('success', $request['Fname'] . ' ' . $request['Sname'] . ' has been added successfully!');
     $data = array('name' => $user->name, 'username' => $user->email, 'password' => $password);
     \Mail::send('emails.registrationConfirmation', $data, function ($message) use($user) {
         $message->from('*****@*****.**', 'Siyaleader');
         $message->to($user->username)->subject("Siyaleader User Registration Confirmation: " . $user->name);
     });
     return redirect('list-users');
 }
    /**
     * PROJECT_TYPE vs PROVINCE vs DISTRICT
     */
    public function project_type_province_district($project_type_key, $province_key, $district_key, Request $request)
    {
        $district = District::findByKey($district_key)->first();
        if (is_null($district)) {
            $district = District::where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->first();
        }
        $province = $district->province;
        $wards = $district->wards()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
        $limit = Config::findByKey('rows_per_page_project')->first()->value;
        $project_type = Project_type::findByKey($project_type_key)->first();
        if (is_null($project_type)) {
            $project_type = Project_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->first();
        }
        $projects = Project::where('project_type_id', $project_type->id)->where('district_id', $district->id)->where('active', 1);
        $projects = $projects->orderBy('priority')->orderBy('created_at', 'desc')->paginate($limit);
        $searchDescription = $project_type->name . ' ' . $province->name . ' ' . $district->name;
        $link = route('project_type_province_district', ['project_type_key' => $project_type->key, 'province_key' => $province->key, 'district_key' => $district->key]);
        $breadcrumb = '<ul class="breadcrumb"> 
		<li class="active"><a href="' . route('homepage') . '">Trang chủ</a></li> 
		<li class="active"><a href="' . route('projects') . '">Dự án</a></li> 
		<li class="active"><a href="' . route('project_type', ['project_type_key' => $project_type->key]) . '">' . $project_type->name . '</a></li> 
		<li class="active"><a href="' . route('project_type_province', ['project_type_key' => $project_type->key, 'province_key' => $province->key]) . '">' . $province->name . '</a></li> 
		<li class=""><a href="' . $link . '">' . $district->name . '</a></li> 
		</ul>';
        $heading = $project_type->name . ' ' . $province->name . ' ' . $district->name;
        $this->setMetadata($searchDescription);
        return view('frontend.sites1.project_search', ['projects' => $projects, 'project_type' => $project_type, 'province' => $province, 'district' => $district, 'wards' => $wards, 'search_type' => 'project_type_province_district', 'link' => $link, 'searchDescription' => $searchDescription, 'breadcrumb' => $breadcrumb, 'heading' => $heading]);
    }
Exemple #10
0
Route::get('reports-list', ['middleware' => 'auth', 'uses' => 'ReportsController@index']);
Route::post('filterReports', ['middleware' => 'auth', 'uses' => 'ReportsController@show']);
/*
|--------------------------------------------------------------------------
| END REPORTS ROUTING
|--------------------------------------------------------------------------
|
*/
$router->resource('users', 'UserController');
Route::get('/api/dropdown/{to}/{from}', function ($to, $from) {
    $name = Input::get('option');
    if ($from == 'province') {
        $object = Province::where('slug', '=', $name)->first();
    }
    if ($from == 'district') {
        $object = District::where('slug', '=', $name)->first();
    }
    if ($from == 'municipality') {
        $object = Municipality::where('slug', '=', $name)->first();
    }
    $listing = DB::table($to)->where($from, $object->id)->lists('name', 'slug');
    return $listing;
});
Route::get('/api/dropdownDepartment/{to}/{from}', function ($to, $from) {
    $name = Input::get('option');
    if ($from == 'department') {
        $object = Department::where('slug', '=', $name)->first();
        $listing = DB::table('categories')->where('department', '=', $object->id)->lists('name', 'slug');
    }
    if ($from == 'category') {
        $object = Category::where('slug', '=', $name)->first();
Exemple #11
0
    $cacheimage = Image::cache(function ($image) use($src, $w, $h) {
        return $image->make("admin/dist/img/" . $src)->resize($w, $h);
    }, 2, true);
    //dd($cachedimage);
    return Response::make($cacheimage, 200, array('Content-Type' => 'image/png'));
});
/*
|--------------------------------------------------------------------------
| User Routes
|--------------------------------------------------------------------------
|         here is where all user's route located 
|
*/
Route::get('getDistrict', function () {
    $prov_id = Input::get('prov_id');
    $district = District::where('province_id', '=', $prov_id)->get();
    return Response::json($district);
});
Route::get('getSector', function () {
    $distr_id = Input::get('distr_id');
    $sector = Sector::where('district_id', '=', $distr_id)->get();
    return Response::json($sector);
});
Route::get('getCell', function () {
    $sect_id = Input::get('sect_id');
    $cell = Cell::where('sector_id', '=', $sect_id)->get();
    return Response::json($cell);
});
Route::get('getMarket', function () {
    $cell_id = Input::get('cell_id');
    $mark = Market::where('cell_id', '=', $cell_id)->get();
Exemple #12
0
     $amenities = PropertyFeatures::where('property_id', $property->id)->get()[0];
     return view('edit_property', ['property' => $property, 'cities' => $cities, 'amenities' => $amenities]);
 });
 Route::get('/property/edit/photos/{property_id}', function ($property_id) {
     $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;
 /**
  * List District by province id ajax.
  */
 public function getDistrictsByProvince($province_id)
 {
     $districts = District::where('province_id', $province_id)->orderBy('priority')->get();
     return $districts->toArray();
 }
 public function getMymenshinghDis()
 {
     /* Current Month Total Day Count Start */
     $date = new \DateTime("-6");
     $date->modify("-" . ($date->format('j') - 1) . " days");
     $month = date('m');
     $year = date("Y");
     $start_date = "01-" . $month . "-" . $year;
     $start_time = strtotime($start_date);
     $end_time = strtotime("+1 month", $start_time);
     for ($i = $start_time; $i < $end_time; $i += 86400) {
         $list[] = date('Y-m-d', $i);
         $list1[] = date('d D', $i);
     }
     $daycount = count($list);
     //return count($list);
     /************ Current Month Total Day Count End **************/
     /*********** Current Month Total weekend Count Start ***********/
     $t = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y')));
     $e = date('Y-m-d', mktime(0, 0, 0, date('m') + 1, 0, date('Y')));
     $begin = new \DateTime($t);
     $end = new \DateTime($e);
     $interval = new \DateInterval('P1D');
     $daterange = new \DatePeriod($begin, $interval, $end);
     $weekends = [];
     foreach ($daterange as $date) {
         if (in_array($date->format('N'), [5])) {
             $weekends[$date->format('W')][] = $date->format('Y-m-d');
         }
     }
     $week = count($weekends);
     /************ Current Month Total weekend Count End ****************/
     $workday = $daycount - $week;
     /************ Current Month Teacher Attdence Percentage Start ****************/
     $teacher = Teacher::all()->count();
     $allteacherworkday = $workday * $teacher;
     //return $allteacherworkday;
     $m = date("Y-m");
     $mymenshinghdivision = District::where('division_id', '=', 8)->orderBy('district', 'ASC')->get();
     return view('admin.reports.dismymenshingh', ['mymenshinghdivision' => $mymenshinghdivision, 'allteacherworkday' => $allteacherworkday, 'm' => $m]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function captureCaseUpdate(CaseRequest $request)
 {
     $houseHolderId = $request['hseHolderId'];
     $userRole = UserRole::where('name', '=', 'House Holder')->first();
     if ($houseHolderId < 1) {
         $user = new User();
         $user->role = $userRole->id;
         $user->name = $request['name'];
         $user->surname = $request['surname'];
         $user->cellphone = $request['cellphone'];
         $user->id_number = $request['id_number'];
         $user->position = $request['position'];
         $user->title = $request['title'];
         $user->house_number = $request['house_number'];
         $user->email = $request['cellphone'] . "@siyaleader.net";
         $user->created_by = \Auth::user()->id;
         $language = Language::where('slug', '=', $request['language'])->first();
         $user->language = $language->id;
         $province = Province::where('slug', '=', $request['province'])->first();
         $user->province = $province->id;
         $district = District::where('slug', '=', $request['district'])->first();
         $user->district = $district->id;
         $municipality = Municipality::where('slug', '=', $request['municipality'])->first();
         $user->municipality = $municipality->id;
         $ward = Ward::where('slug', '=', $request['ward'])->first();
         $user->ward = $ward->id;
         $user->save();
     }
     $casePriority = CasePriority::where('slug', '=', $request['priority'])->first();
     $case = CaseReport::find($request['caseID']);
     $case->description = $request['description'];
     $case->priority = $casePriority->id;
     $case->updated_by = \Auth::user()->id;
     $case->updated_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString();
     $case->save();
     return 'ok';
 }
 public function __construct(Branch $branch, State $state, District $district)
 {
     $this->branch = $branch->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account'));
     $this->district = $district->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account'));
     $this->state = $state->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account'));
 }
 public function searchPlaces(Request $request)
 {
     $data = $request->all();
     $properties = DB::table('properties')->where('owner_id', '!=', Auth::id());
     if ($request->has('city')) {
         $city = City::where('name', $data['city'])->first();
         $properties = $properties->where('city_id', '=', $city->id);
     }
     if ($request->has('district')) {
         $district = District::where('name', $data['district'])->first();
         $properties = $properties->where('district_id', '=', $district->id);
     }
     if ($request->has('type')) {
         $properties = $properties->where('type', '=', $data['type']);
     }
     if ($request->has('min_occupancy')) {
         $properties = $properties->where('max_occupancy', '>=', $data['min_occupancy']);
     }
     if ($request->has('max_occupancy')) {
         $properties = $properties->where('max_occupancy', '<=', $data['max_occupancy']);
     }
     if ($request->has('min_price_per_night')) {
         $properties = $properties->where('price_per_night', '>=', $data['min_price_per_night']);
     }
     if ($request->has('max_price_per_night')) {
         $properties = $properties->where('price_per_night', '<=', $data['max_price_per_night']);
     }
     $properties = $properties->join('property_features', 'properties.id', '=', 'property_features.property_id');
     if ($request->has('kitchen')) {
         $properties = $properties->where('kitchen', '=', on2true($data['kitchen']));
     }
     if ($request->has('internet')) {
         $properties = $properties->where('internet', '=', on2true($data['internet']));
     }
     if ($request->has('tv')) {
         $properties = $properties->where('tv', '=', on2true($data['tv']));
     }
     if ($request->has('essentials')) {
         $properties = $properties->where('essentials', '=', on2true($data['essentials']));
     }
     if ($request->has('shampoo')) {
         $properties = $properties->where('shampoo', '=', on2true($data['shampoo']));
     }
     if ($request->has('heating')) {
         $properties = $properties->where('heating', '=', on2true($data['heating']));
     }
     if ($request->has('air_conditioning')) {
         $properties = $properties->where('air_conditioning', '=', on2true($data['air_conditioning']));
     }
     if ($request->has('washer')) {
         $properties = $properties->where('washer', '=', on2true($data['washer']));
     }
     if ($request->has('dryer')) {
         $properties = $properties->where('dryer', '=', on2true($data['dryer']));
     }
     if ($request->has('free_parking_on_premises')) {
         $properties = $properties->where('free_parking_on_premises', '=', on2true($data['free_parking_on_premises']));
     }
     if ($request->has('wireless_internet')) {
         $properties = $properties->where('wireless_internet', '=', on2true($data['wireless_internet']));
     }
     if ($request->has('cable_tv')) {
         $properties = $properties->where('cable_tv', '=', on2true($data['cable_tv']));
     }
     if ($request->has('breakfast')) {
         $properties = $properties->where('breakfast', '=', on2true($data['breakfast']));
     }
     if ($request->has('pets_allowed')) {
         $properties = $properties->where('pets_allowed', '=', on2true($data['pets_allowed']));
     }
     if ($request->has('family_kid_friendly')) {
         $properties = $properties->where('family_kid_friendly', '=', on2true($data['family_kid_friendly']));
     }
     if ($request->has('suitable_for_events')) {
         $properties = $properties->where('suitable_for_events', '=', on2true($data['suitable_for_events']));
     }
     if ($request->has('smoking_allowed')) {
         $properties = $properties->where('smoking_allowed', '=', on2true($data['smoking_allowed']));
     }
     if ($request->has('wheelchair_accessible')) {
         $properties = $properties->where('wheelchair_accessible', '=', on2true($data['wheelchair_accessible']));
     }
     if ($request->has('elevator_in_building')) {
         $properties = $properties->where('elevator_in_building', '=', on2true($data['elevator_in_building']));
     }
     if ($request->has('indoor_fireplace')) {
         $properties = $properties->where('indoor_fireplace', '=', on2true($data['indoor_fireplace']));
     }
     if ($request->has('buzzer_wireless_intercom')) {
         $properties = $properties->where('buzzer_wireless_intercom', '=', on2true($data['buzzer_wireless_intercom']));
     }
     if ($request->has('doorman')) {
         $properties = $properties->where('doorman', '=', on2true($data['doorman']));
     }
     if ($request->has('pool')) {
         $properties = $properties->where('pool', '=', on2true($data['pool']));
     }
     if ($request->has('hot_tub')) {
         $properties = $properties->where('hot_tub', '=', on2true($data['hot_tub']));
     }
     if ($request->has('gym')) {
         $properties = $properties->where('gym', '=', on2true($data['gym']));
     }
     if ($request->has('feature_24_hour_check_in')) {
         $properties = $properties->where('feature_24_hour_check_in', '=', on2true($data['feature_24_hour_check_in']));
     }
     if ($request->has('hangers')) {
         $properties = $properties->where('hangers', '=', on2true($data['hangers']));
     }
     if ($request->has('iron')) {
         $properties = $properties->where('iron', '=', on2true($data['iron']));
     }
     if ($request->has('hair_dryer')) {
         $properties = $properties->where('hair_dryer', '=', on2true($data['hair_dryer']));
     }
     if ($request->has('laptop_friendly_workspace')) {
         $properties = $properties->where('laptop_friendly_workspace', '=', on2true($data['laptop_friendly_workspace']));
     }
     $properties = $properties->get();
     foreach ($properties as $property) {
         $property->id = $property->property_id;
         $property->city_name = City::find($property->city_id)->name;
         $photo_ids = PropertyPictureBridge::where('property_id', $property->id)->get();
         if (count($photo_ids) < 1) {
             $property->image_url = env('PLACEHOLDER_IMAGE_URL');
         } else {
             $property->image_url = Picture::find($photo_ids[0]->picture_id)->url;
         }
     }
     $cities = City::all();
     return redirect(url('/places/searchresult'))->with(['properties' => $properties, 'cities' => $cities]);
 }
 public function studentRegister()
 {
     $this->setMetadata('Đăng ký tìm gia sư');
     $districts = District::where('is_publish', 1)->get();
     $subjects = Subject::where('is_publish', 1)->orderBy('priority')->get();
     $teachTimes = TeachTime::where('is_publish', 1)->orderBy('priority')->get();
     return view('frontend.sites.studentRegister', ['districts' => $districts, 'subjects' => $subjects, 'teachTimes' => $teachTimes]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(UpdateUserRequest $request)
 {
     $user = User::where('id', $request['userID'])->first();
     $role = UserRole::where('slug', '=', $request['role'])->first();
     $user->role = $role->id;
     $title = Title::where('slug', '=', $request['title'])->first();
     $user->title = $title->id;
     $user->name = $request['name'];
     $user->surname = $request['area'];
     $user->id_number = $request['id_number'];
     $user->alt_cellphone = $request['alt_cellphone'];
     $user->alt_email = $request['alt_email'];
     $province = Province::where('slug', '=', $request['province'])->first();
     $user->province = $province->id;
     $district = District::where('slug', '=', $request['district'])->first();
     $user->district = $district->id;
     $municipality = Municipality::where('slug', '=', $request['municipality'])->first();
     $user->municipality = $municipality->id;
     $ward = Ward::where('slug', '=', $request['ward'])->first();
     $user->ward = $ward->id;
     $user->area = $request['area'];
     $user->updated_by = \Auth::user()->id;
     $user->updated_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString();
     $user->save();
     \Session::flash('success', 'well done! User ' . $request['name'] . ' has been successfully updated!');
     return redirect()->back();
 }