<?php

namespace App\Livewire\FormBuilder;


use App\Models\FormBuilder;
use Livewire\WithPagination;
use Livewire\Component;

class Content extends Component
{
    use WithPagination;

    public $table_id='';
    
    public $findTable = '';

    public function getTable($id)
    {
        $this->table_id = $id;
    }

    public function updatedSearch(){
        $this->resetPage();
    }

    public function render()
    {
        $query = FormBuilder::query();  // Replace with your model or query builder

        // Apply search term if present
        if (!empty($this->findTable)) {
            $query->where('name', 'like', '%' . $this->findTable . '%');
        }
    
        $tables = $query->paginate(2);  // Adjust pagination as needed
    
        return view('livewire.form-builder.content',compact('tables'));
    }
}
