/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $municipality = Municipality::find(intval($id));
     $county = County::find(intval($municipality['county_id']));
     $items = Village::where('municipality_id', intval($id))->get();
     return view('poi.municipality.show')->with('municipality', $municipality)->with('county', $county)->with('items', $items);
 }
示例#2
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         County::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $region = Region::raw()->findOne(['_id' => intval($id)]);
     $items = County::where('region_id', intval($id))->get();
     return view('poi.region.show')->with('region', $region)->with('items', $items);
 }
 public function processFacilityFile()
 {
     ini_set('max_execution_time', 300);
     $filePath = storage_path('exports') . '/eHealthKenyaFacilities.xlsx';
     \Excel::load($filePath, function ($reader) {
         $provinces = [];
         $counties = [];
         $subcounties = [];
         $facilities = [];
         $results = $reader->get();
         foreach ($results as $sheet) {
             foreach ($sheet as $row) {
                 $mfl = $row->facility_code;
                 $fname = $row->facility_name;
                 $province = $row->province;
                 $county = $row->county;
                 $subcounty = $row->district;
                 $facilityarr = ['mfl' => $mfl, 'facilityname' => $fname, 'subcounty' => $subcounty];
                 $subcountyarr = ['subcounty' => $subcounty, 'county' => $county];
                 if (!in_array($county, $counties)) {
                     $counties[] = $county;
                 }
                 if (!in_array($subcountyarr, $subcounties)) {
                     $subcounties[] = $subcountyarr;
                 }
                 if (!in_array($facilityarr, $facilities)) {
                     $facilities[] = $facilityarr;
                 }
             }
         }
         //insert counties
         //alter table county auto_increment=1;
         foreach ($counties as $county) {
             $countyModel = new County();
             $countyModel->name = $county;
             $countyModel->save();
         }
         $dbCounties = County::all();
         foreach ($subcounties as $sc) {
             $scname = $sc['subcounty'];
             $countyName = $sc['county'];
             $countyId = 0;
             foreach ($dbCounties as $dbs) {
                 if ($countyName == $dbs->name) {
                     $countyId = $dbs->id;
                     break;
                 }
                 //echo $dbs->id.' '. $dbs->name.'<br/>';
             }
             $newSubCounty = new SubCounty();
             $newSubCounty->name = $scname;
             $newSubCounty->county_id = $countyId;
             $newSubCounty->save();
         }
         $dbSubCounties = SubCounty::all();
         $facilityarr = ['mfl' => $mfl, 'facilityname' => $fname, 'subcounty' => $subcounty];
         foreach ($facilities as $f) {
             $mfl = $f['mfl'];
             $fname = $f['facilityname'];
             $scName = $f['subcounty'];
             $scountyId = 0;
             foreach ($dbSubCounties as $dbsc) {
                 if ($scName == $dbsc->name) {
                     $scountyId = $dbsc->id;
                     break;
                 }
             }
             $newFacility = new Facility();
             $newFacility->mfl_code = $mfl;
             $newFacility->subcounty_id = $scountyId;
             $newFacility->name = $fname;
             $newFacility->save();
         }
     });
     Session::flash('success', 'uploaded file is not valid');
     return redirect('/facility-upload');
 }
 public function geo($id)
 {
     $county = County::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($county['geo']));
 }
 public function getCountyByCitycode()
 {
     $citycode = Input::get('citycode');
     $county = County::where('citycode', $citycode)->get();
     return json_encode(array('result' => true, 'county' => $county));
 }
示例#7
0
 public function destroy($id)
 {
     County::find($id)->delete();
     $counties = County::orderBy('county')->paginate(env('COUNTY_PAGINATION_MAX'));
     return view('counties.index')->with('counties', $counties);
 }