good morning, I'm trying to use searchpane with laravel 10 and Yajra and datatables but currently the panels are empty and I don't understand what I have to do to fill them with database records, here is the code I'm using but I still don't understand the part I have to insert in block to see the values from the database, can anyone help me?
I'm looking everywhere but I can't find anything that helps me understand what I have to do to fill the searchPane panel, I changed the method because the data in the tables are many and with this method I can load tables with lots of data in a few seconds but I can't see the panel as I saw it before
<?php
namespace App\DataTables;
use App\Models\Ticket;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Support\Facades\DB;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Facades\DataTables;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Html\Editor\Editor;
use Yajra\DataTables\Html\Editor\Fields;
use Yajra\DataTables\Html\SearchPane;
use Yajra\DataTables\Services\DataTable;
use Yajra\DataTables\Html\ColumnDefinition;
class TicketsDataTable extends DataTable
{
/**
* Build the DataTable class.
*
* @param QueryBuilder $query Results from query() method.
*/
public function dataTable(QueryBuilder $query): EloquentDataTable
{
return (new EloquentDataTable($query))->setRowId('id');
}
/**
* Get the query source of dataTable.
*/
public function query(Ticket $model): QueryBuilder
{
return $model->newQuery();
}
/**
* Optional method if you want to use the html builder.
*/
public function html(): HtmlBuilder
{
return $this->builder()
->setTableId('tickets-table')
->columns($this->getColumns())
->addColumnDef([
'searchPanes' => ['show' => true],
'targets' => ['_all'],
])
->minifiedAjax()
->orderBy(1)
->selectStyleSingle()
->serverSide(true)
->processing(true)
->stateSave(true)
->select(true)
->fixedHeader(true)
->deferRender(true)
->orderCellsTop(true)
->lengthChange(true)
->autoWidth(false)
->responsive(true)
->searchPanes(true)
->editors([
Editor::make()
->fields([
Fields\Text::make('id'),
Fields\Text::make('tipo'),
Fields\Text::make('stato'),
Fields\Text::make('segnalazione'),
Fields\Text::make('priorita'),
Fields\Text::make('chiusura'),
Fields\Text::make('categoria'),
]),
])
->buttons([
Button::make('create')->editor('editor'),
Button::make('edit')->editor('editor'),
Button::make('remove')->editor('editor'),
Button::make('excel'),
Button::make('csv'),
Button::make('pdf'),
Button::make('print'),
Button::make('reset'),
Button::make('reload')
])
->parameters([
'dom' => '<PBfrt<t>lip>',
'language' => ['url' => url('vendors/it-IT.json')],
]);
}
/**
* Get the dataTable columns definition.
*/
public function getColumns(): array
{
return [
Column::make('id'),
Column::make('tipo'),
Column::make('stato'),
Column::make('segnalazione'),
Column::make('priorita'),
Column::make('chiusura'),
Column::make('categoria'),
];
}
/**
* Get the filename for export.
*/
protected function filename(): string
{
return 'Tickets_' . date('YmdHis');
}
}
now i entered this
public function dataTable(QueryBuilder $query): EloquentDataTable
{
return (new EloquentDataTable($query))->setRowId('id')
->searchPane(
'id',
[
[
'value' => 'id',
'label' => 'id',
],
],
fn() => Ticket::query()->select('id as value', 'id as label')->get(),
function (\Illuminate\Database\Eloquent\Builder $query, array $values) {
return $query
->whereIn(
'id',
'tipo',
$values);
}
);
}
and i see
[searchPane][1]
but how to write the code to see the real id from the database?
[1]: https://i.postimg.cc/NfHNKDTg/ecb6d5657d2d48e7cb600868b7d16c82.png