add handicap mgmt
This commit is contained in:
@@ -183,6 +183,27 @@ Route::get('/lot/manage/{id}', function(\Illuminate\Http\Request $request, $id){
|
||||
return view('lot.manageone', ['lot' => $lot, 'stalls' => $stalls, 'thruid' => $id]);
|
||||
});
|
||||
|
||||
Route::post('/lot/manage/{id}', function(\Illuminate\Http\Request $request, $id){
|
||||
// dd($request->get('handicaps'));
|
||||
$lot = ParkingLot::find($id);
|
||||
$handicaps = json_decode($request->get('handicaps'));
|
||||
$db = new FirestoreClient();
|
||||
|
||||
$stalls_docref = $db->collection('lots')->document($lot->firebase_id)->collection('stalls');
|
||||
$docs = $stalls_docref->documents();
|
||||
|
||||
foreach( $docs as $doc ){
|
||||
if ( $doc->exists()){
|
||||
$data = $stalls_docref->document($doc->id())->snapshot()->data();
|
||||
$data['handicap'] = (in_array($doc->id(), $handicaps));
|
||||
$stalls_docref->document($doc->id())->set($data);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect(url('/lot/manage/'.$id));
|
||||
|
||||
});
|
||||
|
||||
Route::get('/device/add', function(){
|
||||
return view('device.add');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user