<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\HasMany;

class SectionPlacementBatch extends BaseModel
{
    protected $table = 'section_placement_batches';

    public const STATUS_DRAFT = 'draft';
    public const STATUS_FINALIZED = 'finalized';
    public const STATUS_CANCELLED = 'cancelled';
    public const STATUS_SUPERSEDED = 'superseded';

    protected $fillable = [
        'from_school_year',
        'to_school_year',
        'from_grade_level_id',
        'to_grade_level_id',
        'section_capacity_used',
        'total_students',
        'section_count',
        'algorithm',
        'configuration_snapshot_json',
        'preview_snapshot_json',
        'created_by',
        'finalized_by',
        'finalized_at',
        'status',
    ];

    protected $casts = [
        'from_grade_level_id' => 'integer',
        'to_grade_level_id' => 'integer',
        'section_capacity_used' => 'integer',
        'total_students' => 'integer',
        'section_count' => 'integer',
        'created_by' => 'integer',
        'finalized_by' => 'integer',
        'finalized_at' => 'datetime',
    ];

    public function students(): HasMany
    {
        return $this->hasMany(SectionPlacementBatchStudent::class, 'batch_id');
    }
}
