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, 'organization_id' => $this->organization_id, 'branch_id' => $this->branch_id, 'department_id' => $this->department_id, 'division_id' => $this->division_id, 'listing_id' => $this->listing_id, 'category_type' => $this->category_type, 'category' => $this->category, 'campaign_id' => $this->campaign_id, 'country_id' => $this->country_id, 'region_id' => $this->region_id, 'location_id' => $this->location_id, 'sublocation_id' => $this->sublocation_id, 'building_id' => $this->building_id, 'tower_id' => $this->tower_id, 'contact_id' => $this->contact_id, 'lead_type' => $this->lead_type, 'ref' => $this->ref, 'ref_source' => $this->ref_source, 'name' => $this->name, 'gender' => $this->gender, 'email' => $this->email, 'phone' => $this->phone, 'mobile' => $this->mobile, 'whatsapp' => $this->whatsapp, 'source' => $this->source, 'medium' => $this->medium, 'timezone' => $this->timezone, 'contact_at' => $this->contact_at, 'website' => $this->website, '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, 'lead_info' => $this->lead_info, 'cc_note' => $this->cc_note, 'notes' => $this->notes, 'status' => $this->status, 'status_category' => $this->status_category, 'nationality' => $this->nationality, 'language' => $this->language, 'page_name' => $this->page_name, 'source_url' => $this->source_url, 'budget' => $this->budget, 'timeline' => $this->timeline, 'interest' => $this->interest, 'audios' => $this->audios, 'form_name' => $this->form_name, 'project_name' => $this->project_name, 'client_ip' => $this->client_ip, 'client_location' => $this->client_location, 'utms' => $this->utms, 'social_ids' => $this->social_ids, 'qualified_by' => $this->qualified_by, 'created_by' => $this->created_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('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; } }