first commit
This commit is contained in:
32
app/Http/Resources/CourseResource.php
Normal file
32
app/Http/Resources/CourseResource.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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)
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user