EscolaLMS/Courses

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

Summary

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

namespace EscolaLms\Courses\Http\Resources;

use EscolaLms\Courses\Models\Topic;

class LessonSimpleResource extends LessonResource
{
    public function toArray($request): array
    {
        return parent::toArray($request) +
            [
                'topics' => TopicSimpleResource::collection($this->topics->filter(fn (Topic $topic) => $topic->active)->sortBy('order')),
            ];
    }
}