/** * Run the database seeds. * * @return void */ public function run() { // Insert dummy record Centre::create(['name' => 'Henderson', 'address' => '117 Bukit Merah View', 'postal_code' => '151117', 'lng' => 103.82190657700056, 'lat' => 1.2843010410004467]); Centre::create(['name' => 'Dakota Crescent', 'address' => '62 Dakota Crescent', 'postal_code' => '390062', 'lng' => 103.889069356, 'lat' => 1.3076509340004]); Centre::create(['name' => 'Toa Payoh', 'address' => '169 Toa Payoh Lorong 1', 'postal_code' => '310169', 'lng' => 103.84266425, 'lat' => 1.3317424160005]); Centre::create(['name' => 'Singapore General Hospital', 'address' => '1 Hospital Drive, 169608, Singapore', 'postal_code' => '169608', 'lng' => 103.835499702, 'lat' => 1.2798006200005]); Centre::create(['name' => 'Bukit Merah Polyclinic', 'address' => '163 Bukit Merah Central, 150163, Singapore', 'postal_code' => '150163', 'lng' => 103.816965114, 'lat' => 1.2837871400004]); Centre::create(['name' => 'Queenstown Polyclinic', 'address' => '580 Stirling Road, 148958, Singapore', 'postal_code' => '148958', 'lng' => 103.80115498500055, 'lat' => 1.2985064950004244]); }
/** * Store a new location/centre. * Responds to requests to POST /centres * * @param \App\Http\Requests\CreateCentreRequest $request * @return Response */ public function store(CreateCentreRequest $request) { $errors = array(); $geoInfo = json_decode($this->postalCodeToAddress($request), true); if ($geoInfo['status'] == 'error') { $errors = array_add($errors, 'postal', 'Postal code does not exist.'); } if (count($errors) > 0) { return back()->withErrors($errors)->withInput(); } else { Centre::create(['name' => $request->get('name'), 'address' => $request->get('address_full'), 'postal_code' => $request->get('postal'), 'lng' => $geoInfo['x'], 'lat' => $geoInfo['y']]); return redirect('centres')->with('success', 'Location is added successfully!'); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $centre = Request::all(); Centre::create($centre); return redirect()->route('admin_centres_index')->with('status', 'Centre created'); }