EscolaLMS/Courses

View on GitHub
src/Http/Resources/TopicResourceResource.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php


namespace EscolaLms\Courses\Http\Resources;

use EscolaLms\Courses\Models\TopicResource;
use Illuminate\Http\Resources\Json\JsonResource;

class TopicResourceResource extends JsonResource
{
    public function __construct(TopicResource $resource)
    {
        $this->resource = $resource;
    }

    public function getResource(): TopicResource
    {
        return $this->resource;
    }

    public function toArray($request): array
    {
        return [
            'id' => $this->getResource()->id,
            'path' => $this->getResource()->path,
            'name' => $this->getResource()->name,
            'url' => $this->getResource()->url,
            'topic_id' => $this->getResource()->topic_id,
        ];
    }
}