<?php

namespace App\Models;

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

class PackageAddon extends Model
{
    use HasFactory;

    protected $fillable = [
        'key',
        'label',
        'price_id',
        'extra_photos',
        'extra_guests',
        'extra_gallery_days',
        'active',
        'sort',
        'metadata',
    ];

    protected $casts = [
        'active' => 'boolean',
        'metadata' => 'array',
        'extra_photos' => 'integer',
        'extra_guests' => 'integer',
        'extra_gallery_days' => 'integer',
        'sort' => 'integer',
    ];

    protected function increments(): Attribute
    {
        return Attribute::make(
            get: fn () => [
                'extra_photos' => (int) ($this->extra_photos ?? 0),
                'extra_guests' => (int) ($this->extra_guests ?? 0),
                'extra_gallery_days' => (int) ($this->extra_gallery_days ?? 0),
            ],
        );
    }
}
