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, 'agency_amount' => $this->agency_amount, 'ref' => $this->ref, 'user_id' => $this->user_id, 'status' => $this->status, 'unit_id' => $this->unit_id, 'reservation_type' => $this->reservation_type, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'leasing_type' => $this->leasing_type, 'period_stay' => $this->period_stay, 'renewable' => $this->renewable, 'rent_year' => $this->rent_year, 'contract_rent' => $this->contract_rent, 'renewal_fee' => $this->renewal_fee, 'security_deposite' => $this->security_deposite, 'agency_fee' => $this->agency_fee, 'agency_fee_percent' => $this->agency_fee_percent, 'payment_type' => $this->payment_type, 'observations' => $this->observations, 'notes' => $this->notes, 'documents' => $this->documents, 'contract_signed' => $this->contract_signed, 'contract_date' => $this->contract_date, 'contract_issued_by' => $this->contract_issued_by, 'premises' => $this->premises, 'payment_external_agency' => $this->payment_external_agency, 'ext_agency_name' => $this->ext_agency_name, 'commision' => $this->commision, 'details' => $this->details, 'print_contract_on' => $this->print_contract_on, 'vacating_date' => $this->vacating_date, 'mngmt_amt' => $this->mngmt_amt, 'mngmt_perc' => $this->mngmt_perc, 'tenant_id' => $this->tenant_id, '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('leasing/lease/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('leasing::lease.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('leasing/lease//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('leasing::lease.actions.' . $name); } return $arr; } }