This commit is contained in:
Kavalar 2024-08-29 12:46:28 +03:00
commit d3cda0bd8f
2 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,7 @@ namespace Itguild\EloquentTable;
use Exception;
use Illuminate\Database\Eloquent\Model;
use itguild\forms\debug\Debug;
class EloquentDataProvider
{
@ -19,6 +20,7 @@ class EloquentDataProvider
protected array $options = [];
protected array $meta = [];
protected array $filters = [];
protected string $jsonStr = '';
/**
@ -46,10 +48,9 @@ class EloquentDataProvider
$this->meta['baseUrl'] = $options['baseUrl'] ?? $model->table;
$this->meta['params'] = $options['params'] ?? [];
$this->meta['actions'] = $options['actions'] ?? [];
$this->filters = $options['filters'] ?? [];
$this->createQuery();
$this->jsonStr = (new JSONCreator($this->meta, $this->getCollection()->toArray()))->getJson();
$this->jsonStr = (new JSONCreator($this->meta, $this->getCollection()->toArray(), $this->filters,))->getJson();
}
public function createQuery(): void

View File

@ -7,12 +7,13 @@ class JSONCreator
{
protected array $informationArray = [];
public function __construct(array $meta, array $data)
public function __construct(array $meta, array $data, array $filters = [])
{
$params = empty($meta['params']) ? ["class" => "table table-bordered", "border" => "1"] : $meta['params'];
if ($meta) {
$this->informationArray = [
"meta" => $meta,
"filters" => $filters,
"data" => $data ?? []
];
}