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, 'ref' => $this->ref, 'opportunity_id' => $this->opportunity_id, 'property_by' => $this->property_by, 'customer_by' => $this->customer_by, 'property_id' => $this->property_id, 'status' => $this->status, 'priority' => $this->priority, 'date_time' => $this->date_time, 'description' => $this->description, 'feedbacks' => $this->feedbacks, 'fb_community' => $this->fb_community, 'fb_location' => $this->fb_location, 'fb_floor' => $this->fb_floor, 'fb_view' => $this->fb_view, 'fb_layout' => $this->fb_layout, 'fb_bua' => $this->fb_bua, 'fb_quality' => $this->fb_quality, 'fb_price' => $this->fb_price, 'fb_facilities' => $this->fb_facilities, 'fb_parking' => $this->fb_parking, 'fb_ac_type' => $this->fb_ac_type, 'fb_service_charge' => $this->fb_service_charge, 'fb_furniture' => $this->fb_furniture, 'fb_appliances' => $this->fb_appliances, 'property_type' => $this->property_type, 'category_type' => $this->category_type, 'category' => $this->category, 'beds' => $this->beds, 'region_id' => $this->region_id, 'location_id' => $this->location_id, 'sublocation_id' => $this->sublocation_id, 'building_id' => $this->building_id, 'price' => $this->price, 'bua' => $this->bua, 'furnished' => $this->furnished, 'unit' => $this->unit, 'is_online' => $this->is_online, 'online_url' => $this->online_url, 'calendar_id' => $this->calendar_id, 'calendar_sync_at' => $this->calendar_sync_at, 'user_id' => $this->user_id, 'user_type' => $this->user_type, '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('opportunity/viewing/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('opportunity::viewing.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('opportunity/viewing//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('opportunity::viewing.actions.' . $name); } return $arr; } }