<?php

// app/Models/Form.php

namespace App\Models;

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

class Form extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'configuration',
        'is_published'
    ];

    protected $casts = [
        'configuration' => 'array',
        'is_published' => 'boolean'
    ];

    public function responses()
    {
        return $this->hasMany(FormResponse::class);
    }
}

// app/Models/FormResponse.php

namespace App\Models;

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

class FormResponse extends Model
{
    use HasFactory;

    protected $fillable = [
        'form_id',
        'responses',
        'user_identifier'
    ];

    protected $casts = [
        'responses' => 'array'
    ];

    public function form()
    {
        return $this->belongsTo(Form::class);
    }
}
// quiero que cuando se pulse el btn de generar configuracion del fomrulario se mande al end de guarar folruario y se inserte en mi base de datos
