<?php
// app/Models/Fractional.php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;

class Fractional extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'project_id',
        'section_id',      // 👈 ya no project_id
        'name',
        'svg_data',
        'form_template_id',
        'status',
        'image_id',
    ];

    /*protected $casts = [
        'svg_data' => 'array',
    ];*/

    // 🔧 ESTA RELACIÓN ES OBLIGATORIA
    public function section()
    {
        return $this->belongsTo(\App\Models\Section::class);
    }

    // (Si aún hay código que usa project(), puedes dejarlo temporalmente)
    public function project() // opcional mientras migras vistas/consultas
    {
        return $this->belongsTo(\App\Models\Project::class);
    }

    public function properties()
    {
        return $this->hasMany(Property::class);
    }

    public function formTemplate()
    {
        return $this->belongsTo(FormTemplate::class);
    }

    public function image()
    {
        return $this->belongsTo(Image::class);
    }
}

