Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('facilities')->delete();
     Facility::create(['name' => 'Air Conditioning', 'slug' => str_slug('Air Conditioning')]);
     Facility::create(['name' => 'Bath Towel', 'slug' => str_slug('Bath Towel')]);
     Facility::create(['name' => 'Alarm Radio', 'slug' => str_slug('Alarm Radio')]);
     Facility::create(['name' => 'Cable TV', 'slug' => str_slug('Cable TV')]);
     Facility::create(['name' => 'Coffee Maker', 'slug' => str_slug('Coffee Maker')]);
     Facility::create(['name' => 'Coffee Set', 'slug' => str_slug('Coffee Set')]);
     Facility::create(['name' => 'Complimentary Bottled Water', 'slug' => str_slug('Complimentary Bottled Water')]);
     Facility::create(['name' => 'Directory of Service', 'slug' => str_slug('Directory of Service')]);
     Facility::create(['name' => 'Guest Amenities', 'slug' => str_slug('Guest Amenities')]);
     Facility::create(['name' => 'Hair Dryer', 'slug' => str_slug('Hair Dryer')]);
     Facility::create(['name' => 'Hand Towel', 'slug' => str_slug('Hand Towel')]);
     Facility::create(['name' => 'Hot & Cold Shower', 'slug' => str_slug('Hot & Cold Shower')]);
     Facility::create(['name' => 'Iron/Ironing Board', 'slug' => str_slug('Iron/Ironing Board')]);
     Facility::create(['name' => 'LED TV', 'slug' => str_slug('LED TV')]);
     Facility::create(['name' => 'Mini Bar', 'slug' => str_slug('Mini Bar')]);
     Facility::create(['name' => 'Non-Smoking', 'slug' => str_slug('Non-Smoking')]);
     Facility::create(['name' => 'Refrigerator', 'slug' => str_slug('Refrigerator')]);
     Facility::create(['name' => 'Safe Deposit Box', 'slug' => str_slug('Safe Deposit Box')]);
     Facility::create(['name' => 'Shower', 'slug' => str_slug('Shower')]);
     Facility::create(['name' => 'Slippers', 'slug' => str_slug('Slippers')]);
     Facility::create(['name' => 'Sofa', 'slug' => str_slug('Sofa')]);
     Facility::create(['name' => 'Bathtub', 'slug' => str_slug('Bathtub')]);
     Facility::create(['name' => 'Bath Robe', 'slug' => str_slug('Bath Robe')]);
     Facility::create(['name' => 'Face Towel', 'slug' => str_slug('Face Towel')]);
     Facility::create(['name' => 'Kitchen Equipment', 'slug' => str_slug('Kitchen Equipment')]);
     Facility::create(['name' => 'Daily Newspaper', 'slug' => str_slug('Daily Newspaper')]);
     Facility::create(['name' => 'Ergonomic Desk Chair', 'slug' => str_slug('Ergonomic Desk Chair')]);
 }
Exemplo n.º 2
0
 /**
  * [readFile description]
  * @param  [type] $file       [description]
  * @param  [type] $connection [description]
  * @return [type]             [description]
  */
 public function readFile($file, $connection)
 {
     // if($file['extension']=='csv'||$file['extension']=='xls'){
     $path = Config::get('flysystem.connections.' . $connection . '.path');
     Excel::filter('chunk')->load($path . '/' . $file['path'])->chunk(50, function ($results) {
         // return $results;
         $results->each(function ($row) {
             $facility = Facility::create($row->toArray());
         });
     });
     // return $data;
     // }
 }
Exemplo n.º 3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('facility', function ($slug) {
         return \App\Facility::where('slug', $slug)->first();
     });
     $router->bind('type', function ($slug) {
         return \App\RoomType::where('slug', $slug)->first();
     });
     $router->bind('room', function ($room_no) {
         return \App\Room::where('room_no', $room_no)->first();
     });
     $router->model('reservation', 'App\\Reservation');
     parent::boot($router);
 }
 public function store()
 {
     $input = Request::all();
     Facility::create($input);
     return redirect('regions');
 }
Exemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  App\RoomType $roomType
  * @return Response
  */
 public function edit(RoomType $roomType)
 {
     $facilities = Facility::orderBy('name', 'asc')->get();
     $room_facilities = $roomType->facilities()->lists('facility_id');
     return view('type.edit', compact('roomType', 'facilities', 'room_facilities'));
 }
 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');
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  App\Facility $facility
  * @return Response
  */
 public function destroy(Facility $facility)
 {
     $facility->delete();
     return redirect('/facility');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     //
     $validator = \Validator::make($request->all(), ['title' => 'required', 'city' => 'required']);
     if ($validator->fails()) {
         return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => implode($validator->errors()->all(), '<br>'))));
     }
     DB::beginTransaction();
     $user_id = \Auth::user()->get()->id;
     $property = Property::find($id);
     $property->user_id = $user_id;
     // $property->customer_id = $request->customer_id;
     $property->category_id = $request->category_id;
     $property->currency = $request->currency;
     $property->price = $request->price;
     // $property->discount = $request->discount;
     $property->type = $request->type;
     // $property->publish = $request->publish;
     $property->building_size = $request->building_size;
     $property->land_size = $request->land_size;
     // $property->sold = $request->sold;
     $property->code = $request->code;
     $property->status = $request->status;
     $property->year = $request->year;
     // $property->map_latitude = $request->map_latitude;
     // $property->map_longitude = $request->map_longitude;
     $property->city = $request->city;
     $property->province = $request->province;
     $property->country = $request->country;
     $property->slug = $request->slug;
     // $property->view = $request->view;
     $property->view_north = $request->view_north;
     $property->view_east = $request->view_east;
     $property->view_west = $request->view_west;
     $property->view_south = $request->view_south;
     $property->is_price_request = $request->is_price_request;
     $property->is_exclusive = $request->is_exclusive;
     $property->owner_name = $request->owner_name;
     $property->owner_email = $request->owner_email;
     $property->owner_phone = $request->owner_phone;
     $property->agent_commission = $request->agent_commission;
     $property->agent_contact = $request->agent_contact;
     $property->agent_meet_date = $request->agent_meet_date;
     $property->agent_inspector = $request->agent_inspector;
     $property->sell_reason = $request->sell_reason;
     $property->sell_note = $request->sell_note;
     $property->other_agent = $request->other_agent;
     // $property->display = $request->display;
     $property->orientation = $request->orientation;
     $property->sell_in_furnish = $request->sell_in_furnish;
     $property->lease_period = $request->lease_period;
     $property->lease_year = $request->lease_year;
     // find province, country
     $city = \App\City::where('city_name', $request->city)->first();
     $property->city = $request->city;
     $property->province = $city->province->province_name;
     $property->country = $city->province->country->nicename;
     $property->save();
     Model::unguard();
     // lang
     $language = $property->propertyLanguages()->where('locale', 'en')->first();
     if ($language) {
         $language->title = $request->title;
         $language->description = $request->description;
     } else {
         $language = new \App\PropertyLanguage();
         $language->title = $request->title;
         $language->description = $request->description;
         $language->locale = 'en';
         $language->property_id = $property->id;
     }
     $language->save();
     // distances
     if ($request->distance_value) {
         foreach ($request->distance_value as $key => $value) {
             $distance = \App\Distance::find($request->distance_id[$key]);
             $distance->from = $key;
             $distance->value = $value;
             $distance->unit = $request->distance_unit[$key];
             $distance->save();
         }
     }
     // documents
     // if ($request->documents) {
     //     foreach ($request->documents as $key => $value) {
     //         $document = new \App\Document;
     //         $document->property_id = $property->id;
     //         $document->name = $key;
     //         $document->is_included = $value;
     //         $document->save();
     //     }
     // }
     // facilities
     if ($request->facilities) {
         foreach ($request->facilities as $key => $value) {
             $facility = \App\Facility::find($request->facility_id[$key]);
             $facility->name = $key;
             $facility->description = $value;
             $facility->save();
         }
     }
     // files
     if ($request->hasFile('files')) {
         foreach ($request->file('files') as $key => $value) {
             $destinationPath = 'uploads/property';
             $extension = $value->getClientOriginalExtension();
             $fileName = date('YmdHis') . '_' . $key . '_kibarer_property' . '.' . $extension;
             $value->move($destinationPath, $fileName);
             $propertyFile = new \App\PropertyFile();
             $propertyFile->property_id = $property->id;
             $propertyFile->file = $fileName;
             $propertyFile->save();
         }
     }
     Model::reguard();
     DB::commit();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'update success', 'message' => 'Property has been updated')));
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($property_id)
 {
     //
     $facilities = Facility::all();
     return view('propertyfacility.create')->with('property_id', $property_id)->with('facilities', $facilities);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $facilities = Facility::all()->toArray();
     return Response::json(['data' => $this->facilityTransformer->transformCollection($facilities)], 200, array(), JSON_PRETTY_PRINT);
 }
Exemplo n.º 11
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $facility = Facility::find($id);
     return view('facility')->with('facility', $facility);
 }