| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
- use Illuminate\Support\Facades\Storage;
- use App\Models\StudentContract;
- class StudentContractResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'protocol' => $this->protocol,
- 'student_id' => $this->student_id,
- 'unit_id' => $this->unit_id,
- 'class_package_unit_id' => $this->class_package_unit_id,
- 'signature_date' => $this->signature_date ? Carbon::parse($this->signature_date)->format('d/m/Y') : null,
- 'end_date' => $this->end_date ? Carbon::parse($this->end_date)->format('d/m/Y') : null,
- 'class_quantity' => $this->class_quantity,
- 'weekday' => $this->weekday,
- 'start_time' => $this->start_time,
- 'end_time' => $this->end_time,
- 'second_weekday' => $this->second_weekday,
- 'second_start_time' => $this->second_start_time,
- 'second_end_time' => $this->second_end_time,
- 'due_date' => $this->due_date ? Carbon::parse($this->due_date)->format('d/m/Y') : null,
- 'recurring_day' => $this->recurring_day,
- 'tax_register' => $this->tax_register,
- 'down_payment' => $this->down_payment,
- 'installments' => $this->installments,
- 'early_payment_discount' => $this->early_payment_discount,
- 'material_value' => $this->material_value,
- 'material_installments' => $this->material_installments,
- 'interest_rate' => $this->interest_rate,
- 'payment_method' => $this->payment_method,
- 'fine_cancelled' => $this->fine_cancelled,
- 'status' => $this->status,
- 'file_url' => $this->file_url ? Storage::url($this->file_url) : null,
- 'file_type' => $this->file_type,
- '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'),
- ];
- }
- /**
- * @param \Illuminate\Database\Eloquent\Collection<StudentContract> $resource
- * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection<StudentContractResource>
- */
- public static function collection($resource): AnonymousResourceCollection
- {
- return parent::collection($resource);
- }
- }
|