getRouteKey(); } public function title() { if ($this->title != '') { return $this->title; } if ($this->name != '') { return $this->name; } return 'None'; } public function toArray($request) { return [ 'id' => $this->getRouteKey(), 'title' => $this->title(), 'slug' => $this->slug, 'car_make' => $this->car_make, 'car_model' => $this->car_model, 'car_year' => $this->car_year, 'color' => $this->color, 'vin_number' => $this->vin_number, 'engine_type' => $this->engine_type, 'engine_config' => $this->engine_config, 'export_status' => $this->export_status, 'images' => $this->images, 'price' => $this->price, 'status' => $this->status, 'user_id' => $this->user_id, 'exterior_color' => $this->exterior_color, 'interior_color' => $this->interior_color, 'steering' => $this->steering, 'kilometers' => $this->kilometers, 'location' => $this->location, 'specs' => $this->specs, 'vehicle_type' => $this->vehicle_type, 'cylinders' => $this->cylinders, 'seating_capacity' => $this->seating_capacity, 'transmission' => $this->transmission, 'doors' => $this->doors, 'wheel_size' => $this->wheel_size, 'warranty' => $this->warranty, 'interior' => $this->interior, 'exterior' => $this->exterior, 'safety' => $this->safety, 'comfort_convenience' => $this->comfort_convenience, 'infotainment' => $this->infotainment, 'description' => $this->description, 'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null, 'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null, 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), 'workflow' => $this->workflows(), 'actions' => $this->actions(), ], ]; } /** * Get additional data that should be returned with the resource array. * * @param \Illuminate\Http\Request $request * @return array */ public function with($request) { return [ 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), 'workflow' => $this->workflows(), 'actions' => $this->actions(), ], ]; } /** * Get the workflows for the resource. * * @return array */ private function workflows() { $arr = []; $workflow = $this->resource->workflow(); foreach ($workflow->transitions($this) as $key => $transition) { $name = $transition->getName(); $arr[$key]['url'] = guard_url('car/car/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('car::car.workflow.' . $name); } return $arr; } /** * Get the actions for the resource. * * @return array */ private function actions() { $arr = []; $actions = $this->resource->actions()->details(); foreach ($actions as $key => $action) { $name = $action->name(); $arr[$key]['url'] = guard_url('car/car//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('car::car.actions.' . $name); } return $arr; } }