<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\App;

/**
 * @package App\Models
 * @property int $id
 * @property array $title
 * @property string $created_at
 * @property string $updated_at
 *
//  * @property UsefulInfoItem[] $items
 *
 */
class Problem extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
    ];

    protected $casts = [
        'title' => 'array',
    ];

    public function getTitle(): string
    {
        if (App::isLocale('ru')) {
            return (string) $this->title['ru'];
        }

        return (string) $this->title['uz'];
    }
}
