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, 'property_id' => $this->property_id, 'campaign_id' => $this->campaign_id, 'lead_id' => $this->lead_id, 'organization_id' => $this->organization_id, 'branch_id' => $this->branch_id, 'department_id' => $this->department_id, 'division_id' => $this->division_id, 'score' => $this->score, 'account_id' => $this->account_id, 'contact_id' => $this->contact_id, 'ref' => $this->ref, 'ref_source' => $this->ref_source, 'customer_type' => $this->customer_type, 'category_type' => $this->category_type, 'country_id' => $this->country_id, 'region_id' => $this->region_id, 'fianace' => $this->fianace, 'lead_info' => $this->lead_info, 'cc_note' => $this->cc_note, 'agent_note' => $this->agent_note, 'notes' => $this->notes, 'audios' => $this->audios, 'source' => $this->source, 'medium' => $this->medium, 'stage' => $this->stage, 'documents' => $this->documents, 'photos' => $this->photos, 'medias' => $this->medias, 'share' => $this->share, 'budget' => $this->budget, 'timeline' => $this->timeline, 'interest' => $this->interest, 'expiry_at' => $this->expiry_at, 'notified_at' => $this->notified_at, 'unwanted' => $this->unwanted, 'extend' => $this->extend, 'counters' => $this->counters, 'qualified_by' => $this->qualified_by, 'created_by' => $this->created_by, 'assigned_to' => $this->assigned_to, 'owner_id' => $this->owner_id, 'referred_by' => $this->referred_by, '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/opportunity/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('opportunity::opportunity.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/opportunity//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('opportunity::opportunity.actions.' . $name); } return $arr; } }