/** * Store a newly created area in storage. * * @return Response */ public function store() { $data = Input::all(); $area = Area::create($data); $oc = Occupency::where('area_name', '=', $area->name)->first(); $oc->sound_level = $area->sound; $oc->save(); if ($area) { return Response::json(['error' => 'false', 'data' => $area->toArray()], 200); } return Response::json(['error' => 'true', 'message' => 'Could not create Area'], 400); }
/** * Store a newly created event in storage. * * @return Response */ public function store() { $data = Input::all(); $events = Events::create($data); if ($events) { $oc = Occupency::where('area_name', '=', $events->area)->first(); if ($events->event == 'ENTER') { $oc->user_count = $oc->user_count + 1; } else { $oc->user_count = $oc->user_count - 1; } if ($oc->user_count < 0) { $oc->user_count = 0; } $oc->save(); return Response::json(['error' => 'false', 'data' => $events->toArray()], 200); } return Response::json(['error' => 'true', 'message' => 'Could not create Event'], 400); }
public function run() { Occupency::create(['area_name' => 'Beacon 1', 'user_count' => 0, 'sound_level' => 0]); Occupency::create(['area_name' => 'Beacon 2', 'user_count' => 0, 'sound_level' => 0]); Occupency::create(['area_name' => 'Beacon 3', 'user_count' => 0, 'sound_level' => 0]); }
/** * Remove the specified occupency from storage. * * @param int $id * @return Response */ public function destroy($id) { Occupency::destroy($id); return Redirect::route('occupencies.index'); }