<?php

declare(strict_types=1);

namespace App\Concerns\Filament;

use App\Filament\Tabs\BaseTab;

trait HasTabs
{
    /**
     * Get the tabs for an array key-mapped.
     *
     * @param  class-string<BaseTab>[]  $tabClasses
     */
    public function toArray(array $tabClasses = []): array
    {
        $tabs = [];

        foreach ($tabClasses as $class) {
            if ((new $class)->shouldBeHidden()) {
                continue;
            }
            $tabs[$class::getSlug()] = $class::make();
        }

        return $tabs;
    }
}
