mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
separate customers list in a new page
This commit is contained in:
@@ -25,6 +25,7 @@ class CompanyResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$lastPayment = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->first();
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
@@ -38,7 +39,7 @@ class CompanyResource extends JsonResource
|
||||
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first()),
|
||||
'bookings' => $this->whenLoaded('bookings', $this->bookings()->orderBy('id', 'DESC')->get(), []),
|
||||
'total_payments' => (float) $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'),
|
||||
'last_payment' => $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->first()->created_at->diffForHumans(),
|
||||
'last_payment' => $lastPayment ? $lastPayment->created_at->diffForHumans() : 'No Payments',
|
||||
'personal_banks' => BankResource::collection($this->banks->where('type', BankAccountType::PERSONAL)),
|
||||
'recipient_banks' => [
|
||||
'accounts' => BankResource::collection($this->banks->where('type', BankAccountType::EXTERNAL)),
|
||||
|
||||
Reference in New Issue
Block a user