<?php

declare(strict_types=1);

namespace App\Models;

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

class CartItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'session_id',
        'plan_id',
        'billing_cycle',
        'quantity',
        'config_selections',
        'provisioning_config',
        'coupon_code',
    ];

    protected function casts(): array
    {
        return [
            'quantity' => 'integer',
            'config_selections' => 'array',
            'provisioning_config' => 'array',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function plan(): BelongsTo
    {
        return $this->belongsTo(Plan::class);
    }
}
