Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
back
/
app
/
Http
/
Resources
:
CashFlowDebitToMonthResource.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Http\Resources; use App\Domain\Payment\Enums\PaymentTypeEnum; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class CashFlowDebitToMonthResource extends JsonResource { public function toArray(Request $request): array { $totalCredit = 0; $totalCash = 0; $totalExtradition = 0; if (!$this->total_amount) { $amount = (float)$this->amount; if (isset($this->article->article_type)) { if ($this->article->article_type == 'debit') { if (($this->payment->payment_type != PaymentTypeEnum::PAYMENT_TYPE_MOVING->value) && ($this->payment->payment_type != PaymentTypeEnum::PAYMENT_TYPE_ISSUEANCE->value)) { $totalCredit += $amount; } } } } if (isset($this->payment->payment_type)) { $amount = (float)$this->amount; if ($this->payment->payment_type == PaymentTypeEnum::PAYMENT_TYPE_RECEPTION->value) { $totalCash += $amount; } } if ($this->payment->payment_type == PaymentTypeEnum::PAYMENT_TYPE_ISSUEANCE->value) { $amount = (float)$this->amount; $totalExtradition += $amount; } return [ 'id' => $this->article->id, 'name' => $this->article->name, 'type' => $this->article->article_type, 'total_amount' => $this->total_amount ?? $totalCredit, 'total_cash' => $totalCash, 'total_extradition' => $this->total_extradition ?? $totalExtradition, ]; } }