<?php

declare(strict_types=1);

namespace App\Models;

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

class CollectionSurfaceDefinition extends Model
{
    use HasFactory;

    protected $table = 'collection_surface_definitions';

    protected $fillable = [
        'surface_key',
        'title',
        'description',
        'mode',
        'rules_json',
        'ranking_mode',
        'max_items',
        'is_active',
        'starts_at',
        'ends_at',
        'fallback_surface_key',
    ];

    protected $casts = [
        'rules_json' => 'array',
        'max_items' => 'integer',
        'is_active' => 'boolean',
        'starts_at' => 'datetime',
        'ends_at' => 'datetime',
    ];

    public function placements(): HasMany
    {
        return $this->hasMany(CollectionSurfacePlacement::class, 'surface_key', 'surface_key');
    }
}
