<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MentorSetting extends Model
{
    protected $fillable = [
        'mentor_system_enabled',
        'mentor_plan_price',
        'max_students_per_plan',
    ];

    protected function casts(): array
    {
        return [
            'mentor_system_enabled' => 'boolean',
            'mentor_plan_price' => 'decimal:2',
            'max_students_per_plan' => 'integer',
        ];
    }

    public static function current(): self
    {
        return self::query()->firstOrCreate([], [
            'mentor_system_enabled' => true,
            'mentor_plan_price' => 0,
            'max_students_per_plan' => 20,
        ]);
    }

    public static function enabled(): bool
    {
        return self::current()->mentor_system_enabled;
    }
}
