GIF89; GIF89; %PDF- %PDF-
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace App\Http\Resources;
use App\Domain\Payment\Enums\PaymentTypeEnum;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class CashFlowProjectCreditResource extends JsonResource
{
public function toArray(Request $request): array
{
$totalExtradition = 0;
return [
'id' => $this->id,
'name' => $this->name,
'project' => $this->paymentDistributions->map(function ($item) use (&$totalExtradition) {
if (!$item->project) {
return null;
}
if ($item->payment->payment_type == PaymentTypeEnum::PAYMENT_TYPE_ISSUEANCE->value) {
$amount = (float)$item->amount;
$totalExtradition += $amount;
}
return [
'id' => $item->project->id,
'description' => $item->project->description,
'short_description' => $item->project->short_description,
'offer_number' => $item->project->offer_number,
'object_address' => $item->project->object_address,
'total_extradition' => $totalExtradition,
'payment' => [
'id' => $item->payment->id,
'name' => $item->payment->name,
'amount' => $item->amount,
'status' => $item->payment->status,
'payment_type' => $item->payment->payment_type,
'payment_date' => $item->payment->payment_date,
],
];
})->filter()->values(),
];
}
}