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, 'related_id' => $this->related_id, 'team_id' => $this->team_id, 'agent_id' => $this->agent_id, 'deal_id' => $this->deal_id, 'ref' => $this->ref, 'customer_id' => $this->customer_id, 'supplier_id' => $this->supplier_id, 'purchase_invoice_number' => $this->purchase_invoice_number, 'purchase_order_number' => $this->purchase_order_number, 'company_id' => $this->company_id, 'branch_id' => $this->branch_id, 'unit' => $this->unit, 'location' => $this->location, 'location_id' => $this->location_id, 'sublocation_id' => $this->sublocation_id, 'property_id' => $this->property_id, 'department' => $this->department, 'billing_address' => $this->billing_address, 'mobile' => $this->mobile, 'email' => $this->email, 'serial_no' => $this->serial_no, 'invoice_date' => $this->invoice_date, 'due_date' => $this->due_date, 'bank_account_id' => $this->bank_account_id, 'customer_note' => $this->customer_note, 'status' => $this->status, 'sub_total' => $this->sub_total, 'tax_type' => $this->tax_type, 'tax_rate' => $this->tax_rate, 'tax_amount' => $this->tax_amount, 'discount' => $this->discount, 'discount_type' => $this->discount_type, 'discount_value' => $this->discount_value, 'total' => $this->total, 'total_usd' => $this->total_usd, 'payment_total' => $this->payment_total, 'balance_due' => $this->balance_due, 'message_invoice' => $this->message_invoice, 'message_statement' => $this->message_statement, 'notes' => $this->notes, 'documents' => $this->documents, 'show_footer' => $this->show_footer, 'amount_inwords' => $this->amount_inwords, 'customer_address' => $this->customer_address, 'payment_terms' => $this->payment_terms, 'payment_status' => $this->payment_status, 'pro_forma_id' => $this->pro_forma_id, 'offplan_payment_id' => $this->offplan_payment_id, 'type' => $this->type, 'currency' => $this->currency, 'deal_customer_type' => $this->deal_customer_type, 'ref_client' => $this->ref_client, '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('account/invoice/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('account::invoice.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/invoice//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('account::invoice.actions.' . $name); } return $arr; } }