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 function get($index) { return \App\DeviceStatus::all()->get($index); }