| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
- use Illuminate\Http\Resources\Json\JsonResource;
- class FranchiseeAccountReceiveResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'unit_id' => $this->unit_id,
- 'unit_name' => $this->whenLoaded('unit', fn () => $this->unit?->fantasy_name),
- 'tbr_calculation_id' => $this->tbr_calculation_id,
- 'origin' => $this->origin,
- 'financial_plan_account_id' => $this->financial_plan_account_id,
- 'plan_account' => $this->whenLoaded('planAccount', fn () => $this->planAccount ? [
- 'id' => $this->planAccount->id,
- 'code' => $this->planAccount->code,
- 'description' => $this->planAccount->description,
- ] : null),
- 'order' => $this->order,
- 'history' => $this->history,
- 'value' => $this->value,
- 'paid_value' => $this->paid_value,
- 'due_date' => $this->due_date?->format('Y-m-d'),
- 'discount' => $this->discount,
- 'fees' => $this->fees,
- 'obs' => $this->obs,
- 'asaas_id' => $this->asaas_id,
- 'status' => $this->status,
- 'payment_date' => $this->payment_date?->format('Y-m-d'),
- 'details' => $this->whenLoaded('details', fn () => $this->details->map(fn ($d) => [
- 'id' => $d->id,
- 'value' => $d->value,
- 'history' => $d->history,
- ])),
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
- ];
- }
- public static function collection($resource): AnonymousResourceCollection
- {
- return parent::collection($resource);
- }
- }
|