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(), 'agent_id' => $this->agent_id, 'listing_id' => $this->listing_id, 'category_id' => $this->category_id, 'location_id' => $this->location_id, 'sublocation_id' => $this->sublocation_id, 'property_id' => $this->property_id, 'name_title' => $this->name_title, 'name' => $this->name, 'source' => $this->source, 'email' => $this->email, 'phone' => $this->phone, 'mobile' => $this->mobile, 'contact_at' => $this->contact_at, 'expiry_at' => $this->expiry_at, 'priority' => $this->priority, 'finance' => $this->finance, 'listing_type' => $this->listing_type, 'customer_type' => $this->customer_type, 'min_price' => $this->min_price, 'max_price' => $this->max_price, 'min_area' => $this->min_area, 'max_area' => $this->max_area, 'min_bed' => $this->min_bed, 'max_bed' => $this->max_bed, 'description' => $this->description, 'customer_care_notes' => $this->customer_care_notes, 'qualify' => $this->qualify, 'page_name' => $this->page_name, 'source_url' => $this->source_url, 'lng' => $this->lng, 'form_name' => $this->form_name, 'project_name' => $this->project_name, 'timing' => $this->timing, 'client_ip' => $this->client_ip, 'utm_source' => $this->utm_source, 'utm_medium' => $this->utm_medium, 'utm_campaign' => $this->utm_campaign, 'sub_source' => $this->sub_source, '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(''), ], ]; } /** * 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(), ], ]; } private function workflows() { $arr = []; $workflow = $this->workflow(); foreach ($workflow->transitions($this) as $key => $transition) { $name = $transition->getName(); $arr[$key]['url'] = guard_url('enquiry/enquiry/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('enquiry::enquiry.workflow.' . $name); } return $arr; } private function actions() { $arr = []; $actions = $this->resource->actions()->details(); foreach ($actions as $key => $action) { $name = $action->name(); $arr[$key]['url'] = guard_url('enquiry/enquiry//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('enquiry::enquiry.actions.' . $name); } return $arr; } }