StudentContractInstallmentResource.php 1.1 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Resources;
  3. use Carbon\Carbon;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class StudentContractInstallmentResource extends JsonResource
  7. {
  8. public function toArray(Request $request): array
  9. {
  10. return [
  11. 'id' => $this->id,
  12. 'type' => $this->type,
  13. 'history' => $this->history,
  14. 'order' => $this->order, // "1/12" via accessor
  15. 'installment_number' => $this->installment_number,
  16. 'total_installments' => $this->total_installments,
  17. 'value' => (float) $this->value,
  18. 'paid_value' => (float) $this->paid_value,
  19. 'discount' => (float) $this->discount,
  20. 'fine' => (float) $this->fine,
  21. 'due_date' => $this->due_date
  22. ? Carbon::parse($this->due_date)->format('d/m/Y')
  23. : null,
  24. 'status' => $this->status,
  25. ];
  26. }
  27. }