<?php

namespace App\Services;

use App\Models\GenericBackoffice\Entry;
use App\Libs\Database\Eloquent\Collection\ContentTypeCollection;
use Illuminate\Database\Eloquent\Builder;
use App\Services\DataService;

class PageDataService extends DataService
{
    /**
     * Gets the content pages
     *
     * @return App\Libs\Database\Eloquent\Collection\ContentTypeCollection
     */
    public function list(): ContentTypeCollection
    {
        /** @var Builder $query */
        return Entry::full()
            ->where('status', 'published')
            ->whereNotNull('content_area',)
            ->with('blocks', function ($blocksQ) {
                BlockDataService::applyBlocksQuery($blocksQ);
            })->get();
    }
}
