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, 'project_id' => $this->project_id, 'project_number' => $this->project_number, 'project_name' => $this->project_name, 'developer_id' => $this->developer_id, 'developer_number' => $this->developer_number, 'developer_name' => $this->developer_name, 'master_developer_id' => $this->master_developer_id, 'master_developer_number' => $this->master_developer_number, 'master_developer_name' => $this->master_developer_name, 'project_start_date' => $this->project_start_date, 'project_end_date' => $this->project_end_date, 'project_type_id' => $this->project_type_id, 'project_type_ar' => $this->project_type_ar, 'project_classification_id' => $this->project_classification_id, 'project_classification_ar' => $this->project_classification_ar, 'escrow_agent_id' => $this->escrow_agent_id, 'escrow_agent_name' => $this->escrow_agent_name, 'project_status' => $this->project_status, 'project_status_ar' => $this->project_status_ar, 'percent_completed' => $this->percent_completed, 'completion_date' => $this->completion_date, 'cancellation_date' => $this->cancellation_date, 'project_description_ar' => $this->project_description_ar, 'project_description_en' => $this->project_description_en, 'property_id' => $this->property_id, 'area_id' => $this->area_id, 'area_name_ar' => $this->area_name_ar, 'area_name_en' => $this->area_name_en, 'master_project_ar' => $this->master_project_ar, 'master_project_en' => $this->master_project_en, 'zoning_authority_id' => $this->zoning_authority_id, 'zoning_authority_ar' => $this->zoning_authority_ar, 'zoning_authority_en' => $this->zoning_authority_en, 'no_of_lands' => $this->no_of_lands, 'no_of_buildings' => $this->no_of_buildings, 'no_of_villas' => $this->no_of_villas, 'no_of_units' => $this->no_of_units, '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('map/project/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('map::project.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('map/project//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('map::project.actions.' . $name); } return $arr; } }