public static function fetch_status_history($category_slug) { $json = []; $category = Category::whereSlug($category_slug)->first(); $device_statuses = DeviceStatus::all(); foreach ($device_statuses as $device_status) { if ($device_status->device->category_id == $category->id) { $json[] = ['device_slug' => $device_status->device->slug, 'device_name' => $device_status->device->name, 'user_slug' => $device_status->user->id, 'user_name' => $device_status->user->name, 'status_label' => $device_status->status->status, 'status_descrip' => $device_status->status->description, 'created_at' => date('m/d/Y h:i A', strtotime($device_status->created_at))]; } } return json_encode($json); }
public static function show_device_status($device_slug) { $ctr = 0; $device = Device::whereSlug($device_slug)->first(); $statuses = DeviceStatus::with(['user', 'status'])->where('device_id', $device->id); $statuses = $statuses->latest('device_statuses.created_at')->paginate(25); $statuses->setPath('status'); return view('devices.device_tab.status', compact('statuses', 'ctr', 'device')); }
public function get($index) { return \App\DeviceStatus::all()->get($index); }