<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class GropList extends Model
{
    use HasFactory;

    protected $table = 'groups';

    protected $fillable = [
        'user_id',
        'name',
        'description',
        'color',
    ];

    public function getGroupNameAttribute()
    {
        return $this->attributes['name'] ?? null;
    }

    public function setGroupNameAttribute($value)
    {
        $this->attributes['name'] = $value;
    }

    public function numbers()
    {
        return $this->hasMany(Number::class, 'group_id');
    }
}
