/** * Get all devices which should get deleted. * * @return mixed */ public function getDevices() { $date = Carbon::now()->subMinutes(15); $devices = Device::where('updated_at', '<', $date)->get(); $affectedRows = $devices->count(); foreach ($devices as $device) { $device->delete(); } return $affectedRows; }
/** * Display a listing of the resource. * * @param null $group * * @return Response */ public function index($group = null) { $devices = $group ? Device::where('group', $group)->get() : Device::onHomePage()->get(); return $this->respond(['data' => $this->transformer->transformCollection($devices->all()), 'server_time' => Carbon::now()->toIso8601String()]); }
/** * Show all Devices for the given group. * * @param string $group * * @return Response */ public function show($group) { $devices = Device::where('group', $group)->get(); return view('overview')->with(compact('devices', 'group')); }