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, 'team_id' => $this->team_id, 'agent_id' => $this->agent_id, 'lead_id' => $this->lead_id, 'rotation_id' => $this->rotation_id, 'assigned_id' => $this->assigned_id, 'lead_qualify' => $this->lead_qualify, 'lead_type' => $this->lead_type, 'opportunitable_id' => $this->opportunitable_id, 'opportunitable_type' => $this->opportunitable_type, 'ref_source' => $this->ref_source, 'account_id' => $this->account_id, 'contact_id' => $this->contact_id, 'contact_details' => $this->contact_details, 'ref' => $this->ref, 'title' => $this->title, 'finance' => $this->finance, 'industry' => $this->industry, 'status' => $this->status, 'sub_status' => $this->sub_status, 'priority' => $this->priority, 'customer_type' => $this->customer_type, 'buyer_type' => $this->buyer_type, 'created_by' => $this->created_by, 'description' => $this->description, 'customer_care_notes' => $this->customer_care_notes, 'customer_response' => $this->customer_response, 'commercial' => $this->commercial, 'notes' => $this->notes, 'audios' => $this->audios, 'agent_note' => $this->agent_note, 'probability' => $this->probability, 'source' => $this->source, 'sub_source' => $this->sub_source, 'stage' => $this->stage, 'category_id' => $this->category_id, 'emirate_id' => $this->emirate_id, 'location_id' => $this->location_id, 'sublocation_id' => $this->sublocation_id, 'property_id' => $this->property_id, 'min_bed' => $this->min_bed, 'max_bed' => $this->max_bed, 'min_price' => $this->min_price, 'max_price' => $this->max_price, 'min_area' => $this->min_area, 'max_area' => $this->max_area, 'hot' => $this->hot, 'share' => $this->share, 'budget' => $this->budget, 'timeline' => $this->timeline, 'level_of_interest' => $this->level_of_interest, 'contact_at' => $this->contact_at, 'extended' => $this->extended, 'expiry_at' => $this->expiry_at, 'notified_at' => $this->notified_at, 'listing_type' => $this->listing_type, 'opportunity_lost_reason' => $this->opportunity_lost_reason, 'opportunity_lost_description' => $this->opportunity_lost_description, 'pool_count' => $this->pool_count, 'unwanted_count' => $this->unwanted_count, 'pool_ids' => $this->pool_ids, 'unwanted_ids' => $this->unwanted_ids, 'reminder' => $this->reminder, 'extend_date' => $this->extend_date, 'extend_description' => $this->extend_description, 'counters' => $this->counters, 'contact_medium' => $this->contact_medium, 'user_id' => $this->user_id, 'user_type' => $this->user_type, 'opportunity_status' => $this->opportunity_status, 'customer_engaggement' => $this->customer_engaggement, 'notification_send' => $this->notification_send, '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('lead/lead/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('lead::lead.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('lead/lead//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('lead::lead.actions.' . $name); } return $arr; } }