<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Cucina extends \App\Models\AbstractModels\AbstractCucina
{
    protected $appends = ['coperto_come_piatto', 'colore'];

    public function getCopertoComePiattoAttribute()
    {
        return (bool)($this->info['coperto_come_piatto'] ?? false);
    }

    public function setCopertoComePiattoAttribute($value)
    {
    $info = is_array($this->info) ? $this->info : [];
    $info['coperto_come_piatto'] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
    $this->attributes['info'] = json_encode($info);
    }

    public function getColoreAttribute()
    {
        return $this->info['colore'] ?? '#000000';
    }


    public function setColoreAttribute($value)
    {
    $info = is_array($this->info) ? $this->info : [];
    $info['colore'] = $value;
    $this->attributes['info'] = json_encode($info);
    }

}
