add refund and event logic
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Events;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EventChargeResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this->id ?? 0),
|
||||
'event_id' => (int) ($this->event_id ?? 0),
|
||||
'event_name' => $this->event_name ?? null,
|
||||
'parent_id' => (int) ($this->parent_id ?? 0),
|
||||
'parent_name' => trim(($this->parent_firstname ?? '') . ' ' . ($this->parent_lastname ?? '')),
|
||||
'student_id' => (int) ($this->student_id ?? 0),
|
||||
'student_name' => trim(($this->student_firstname ?? '') . ' ' . ($this->student_lastname ?? '')),
|
||||
'participation' => $this->getRawOriginal('participation') ?? $this->participation,
|
||||
'charged' => (float) ($this->getRawOriginal('charged') ?? $this->charged ?? 0),
|
||||
'school_year' => $this->school_year,
|
||||
'semester' => $this->semester,
|
||||
'created_at' => optional($this->created_at)->toDateTimeString(),
|
||||
'updated_at' => optional($this->updated_at)->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Events;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EventResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this->id ?? 0),
|
||||
'event_name' => $this->event_name,
|
||||
'event_category' => $this->event_category,
|
||||
'description' => $this->description,
|
||||
'amount' => (float) ($this->amount ?? 0),
|
||||
'flyer' => $this->flyer,
|
||||
'expiration_date' => optional($this->expiration_date)->format('Y-m-d'),
|
||||
'semester' => $this->semester,
|
||||
'school_year' => $this->school_year,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => optional($this->created_at)->toDateTimeString(),
|
||||
'updated_at' => optional($this->updated_at)->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Events;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EventStudentChargeResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'name' => $this['name'] ?? '',
|
||||
'charged' => (bool) ($this['charged'] ?? false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Refunds;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RefundResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this->id ?? 0),
|
||||
'parent_id' => (int) ($this->parent_id ?? 0),
|
||||
'invoice_id' => $this->invoice_id ? (int) $this->invoice_id : null,
|
||||
'school_year' => $this->school_year,
|
||||
'semester' => $this->semester,
|
||||
'request' => $this->request,
|
||||
'status' => $this->status,
|
||||
'reason' => $this->reason,
|
||||
'refund_amount' => (float) ($this->refund_amount ?? 0),
|
||||
'refund_paid_amount' => (float) ($this->refund_paid_amount ?? 0),
|
||||
'refund_method' => $this->refund_method,
|
||||
'check_nbr' => $this->check_nbr,
|
||||
'check_file' => $this->check_file,
|
||||
'note' => $this->note,
|
||||
'requested_at' => optional($this->requested_at)->toDateTimeString(),
|
||||
'approved_at' => optional($this->approved_at)->toDateTimeString(),
|
||||
'refunded_at' => optional($this->refunded_at)->toDateTimeString(),
|
||||
'created_at' => optional($this->created_at)->toDateTimeString(),
|
||||
'updated_at' => optional($this->updated_at)->toDateTimeString(),
|
||||
'parent_name' => $this->parent_name ?? null,
|
||||
'approved_by_name' => $this->approved_by_name ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user