<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Harim extends Model
{
    use HasFactory;
    protected $guarded = [];

    public function histories(): HasMany
    {
        return $this->hasMany(HarimHistory::class);
    }

    protected function polygon(): Attribute
    {
        return Attribute::make(
            get: fn($value) => json_decode($value)
        );
    }
}
