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, 'unit_number' => $this->unit_number, 'unit_balcony_area' => $this->unit_balcony_area, 'unit_parking_number' => $this->unit_parking_number, 'parking_allocation_type' => $this->parking_allocation_type, 'parking_allocation_type_ar' => $this->parking_allocation_type_ar, 'parking_allocation_type_en' => $this->parking_allocation_type_en, 'common_area' => $this->common_area, 'actual_common_area' => $this->actual_common_area, 'floor' => $this->floor, 'rooms' => $this->rooms, 'rooms_ar' => $this->rooms_ar, 'rooms_en' => $this->rooms_en, 'actual_area' => $this->actual_area, 'property_type_id' => $this->property_type_id, 'property_type_ar' => $this->property_type_ar, 'property_type_en' => $this->property_type_en, 'property_sub_type_id' => $this->property_sub_type_id, 'property_sub_type_ar' => $this->property_sub_type_ar, 'property_sub_type_en' => $this->property_sub_type_en, 'parent_property_id' => $this->parent_property_id, 'grandparent_property_id' => $this->grandparent_property_id, 'creation_date' => $this->creation_date, 'munc_zip_code' => $this->munc_zip_code, 'munc_number' => $this->munc_number, 'parcel_id' => $this->parcel_id, 'is_free_hold' => $this->is_free_hold, 'is_lease_hold' => $this->is_lease_hold, 'is_registered' => $this->is_registered, 'pre_registration_number' => $this->pre_registration_number, 'master_project_id' => $this->master_project_id, 'master_project_en' => $this->master_project_en, 'master_project_ar' => $this->master_project_ar, 'project_id' => $this->project_id, 'project_name_ar' => $this->project_name_ar, 'project_name_en' => $this->project_name_en, 'land_type_id' => $this->land_type_id, 'land_type_ar' => $this->land_type_ar, 'land_type_en' => $this->land_type_en, 'property_id' => $this->property_id, 'area_id' => $this->area_id, 'zone_id' => $this->zone_id, 'area_name_ar' => $this->area_name_ar, 'area_name_en' => $this->area_name_en, 'land_number' => $this->land_number, 'land_sub_number' => $this->land_sub_number, 'building_number' => $this->building_number, '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/unit/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('map::unit.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/unit//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('map::unit.actions.' . $name); } return $arr; } }