<?php

namespace App\Modules\Admin;

use Illuminate\Database\Eloquent\Model;

class DashboardTabSetting extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'dashboard_tabs_settings';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'tab_key',
        'tab_label',
        'order_index',
        'is_visible',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'is_visible' => 'boolean',
        'order_index' => 'integer',
    ];

    /**
     * Get all visible tabs ordered by order_index
     *
     * @return \Illuminate\Database\Eloquent\Collection
     */
    public static function getVisibleTabs()
    {
        return static::where('is_visible', true)
            ->orderBy('order_index')
            ->get();
    }

    /**
     * Get all tabs ordered by order_index
     *
     * @return \Illuminate\Database\Eloquent\Collection
     */
    public static function getAllTabsOrdered()
    {
        return static::orderBy('order_index')->get();
    }
}
