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, 'company_id' => $this->company_id, 'team_id' => $this->team_id, 'payrecable_id' => $this->payrecable_id, 'payrecable_type' => $this->payrecable_type, 'invoice_type' => $this->invoice_type, 'customer_id' => $this->customer_id, 'supplier_id' => $this->supplier_id, 'agent_id' => $this->agent_id, 'deal_id' => $this->deal_id, 'coa_id' => $this->coa_id, 'customer_name' => $this->customer_name, 'supplier_name' => $this->supplier_name, 'coa_name' => $this->coa_name, 'ref' => $this->ref, 'project_name' => $this->project_name, 'building' => $this->building, 'project_price' => $this->project_price, 'unit' => $this->unit, 'mode' => $this->mode, 'date' => $this->date, 'currency' => $this->currency, 'currency_rate' => $this->currency_rate, 'currency_amount' => $this->currency_amount, 'bank_id' => $this->bank_id, 'cheque_bank' => $this->cheque_bank, 'cheque_no' => $this->cheque_no, 'cheque_date' => $this->cheque_date, 'cheque_clear_date' => $this->cheque_clear_date, 'cheque_status' => $this->cheque_status, 'deal_customer_type' => $this->deal_customer_type, 'payment' => $this->payment, 'receipt' => $this->receipt, 'tax' => $this->tax, 'remarks' => $this->remarks, 'details' => $this->details, 'status' => $this->status, 'user_id' => $this->user_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('account/payrec/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('account::payrec.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('account/payrec//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('account::payrec.actions.' . $name); } return $arr; } }