33 lines
941 B
PHP
33 lines
941 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CourseResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
|
|
return [
|
|
|
|
"id" => $this->id,
|
|
"start_date" => $this->start_date,
|
|
"end_date" => $this->end_date,
|
|
"total_fee" => $this->total_fee,
|
|
"certificate_issued_at" => $this->certificate_issued_at,
|
|
"notes" => $this->notes,
|
|
"paid_amount" => $this->paid_amount,
|
|
"category" => $this->category ? new CategoryResource($this->category):null,
|
|
|
|
'transactions' => TransactionResource::collection($this->allTransactions)
|
|
];
|
|
}
|
|
}
|