<?php

namespace App\Models;

use App\Core\Model;

class DynamicFormSubmission extends Model
{
    protected $table = 'dynamic_form_submissions';
    protected $primaryKey = 'id';

    public function getByForm($formId)
    {
        $stmt = $this->db->prepare("SELECT s.*, u.name as user_name, u.email as user_email FROM {$this->table} s LEFT JOIN users u ON s.user_id = u.id WHERE s.form_id = ? ORDER BY s.submitted_at DESC");
        $stmt->execute([$formId]);
        return $stmt->fetchAll(\PDO::FETCH_OBJ);
    }
}
