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, 'offer_id' => $this->offer_id, 'listing_id' => $this->listing_id, 'opportunity_id' => $this->opportunity_id, 'category_type' => $this->category_type, 'category' => $this->category, 'seller_source' => $this->seller_source, 'buyer_source' => $this->buyer_source, '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, 'ref' => $this->ref, 'type' => $this->type, 'developer_id' => $this->developer_id, 'bua' => $this->bua, 'plot' => $this->plot, 'beds' => $this->beds, 'baths' => $this->baths, 'price' => $this->price, 'plot_area' => $this->plot_area, 'frequency' => $this->frequency, 'furnished' => $this->furnished, 'cheques' => $this->cheques, 'payment_mode' => $this->payment_mode, 'maintenance_fee' => $this->maintenance_fee, 'rent_start_date' => $this->rent_start_date, 'rent_end_date' => $this->rent_end_date, 'next_available' => $this->next_available, 'deposit' => $this->deposit, 'deposit_percent' => $this->deposit_percent, 'commission_buyer' => $this->commission_buyer, 'commission_buyer_percent' => $this->commission_buyer_percent, 'commission_buyer_vat' => $this->commission_buyer_vat, 'commission_seller' => $this->commission_seller, 'commission_seller_percent' => $this->commission_seller_percent, 'commission_seller_vat' => $this->commission_seller_vat, 'company_com_prs' => $this->company_com_prs, 'company_com_amt' => $this->company_com_amt, 'deal_date' => $this->deal_date, 'unit_no' => $this->unit_no, 'agency_agent_name' => $this->agency_agent_name, 'agency_name' => $this->agency_name, 'agency_representing' => $this->agency_representing, 'agency_prs' => $this->agency_prs, 'agency_agents_mobile' => $this->agency_agents_mobile, 'agency_amount' => $this->agency_amount, 'conveyance_fee' => $this->conveyance_fee, 'penalty' => $this->penalty, 'notes' => $this->notes, 'documents' => $this->documents, 'seller_documents' => $this->seller_documents, 'buyer_documents' => $this->buyer_documents, 'payment_date' => $this->payment_date, 'status' => $this->status, 'created_by' => $this->created_by, '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('deal/deal/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('deal::deal.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('deal/deal//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('deal::deal.actions.' . $name); } return $arr; } }