Compare commits
3 Commits
59e065458d
...
b4afddc7f7
Author | SHA1 | Date | |
---|---|---|---|
b4afddc7f7 | |||
50b642be1a | |||
e84051ae21 |
@ -4,6 +4,7 @@ namespace Itguild\EloquentTable;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use itguild\forms\debug\Debug;
|
||||||
|
|
||||||
class EloquentDataProvider
|
class EloquentDataProvider
|
||||||
{
|
{
|
||||||
@ -19,6 +20,7 @@ class EloquentDataProvider
|
|||||||
|
|
||||||
protected array $options = [];
|
protected array $options = [];
|
||||||
protected array $meta = [];
|
protected array $meta = [];
|
||||||
|
protected array $filters = [];
|
||||||
protected string $jsonStr = '';
|
protected string $jsonStr = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,10 +48,9 @@ class EloquentDataProvider
|
|||||||
$this->meta['baseUrl'] = $options['baseUrl'] ?? $model->table;
|
$this->meta['baseUrl'] = $options['baseUrl'] ?? $model->table;
|
||||||
$this->meta['params'] = $options['params'] ?? [];
|
$this->meta['params'] = $options['params'] ?? [];
|
||||||
$this->meta['actions'] = $options['actions'] ?? [];
|
$this->meta['actions'] = $options['actions'] ?? [];
|
||||||
|
$this->filters = $options['filters'] ?? [];
|
||||||
$this->createQuery();
|
$this->createQuery();
|
||||||
|
$this->jsonStr = (new JSONCreator($this->meta, $this->filters, $this->getCollection()->toArray()))->getJson();
|
||||||
$this->jsonStr = (new JSONCreator($this->meta, $this->getCollection()->toArray()))->getJson();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQuery(): void
|
public function createQuery(): void
|
||||||
|
@ -7,12 +7,13 @@ class JSONCreator
|
|||||||
{
|
{
|
||||||
protected array $informationArray = [];
|
protected array $informationArray = [];
|
||||||
|
|
||||||
public function __construct(array $meta, array $data)
|
public function __construct(array $meta, array $filters, array $data)
|
||||||
{
|
{
|
||||||
$params = empty($meta['params']) ? ["class" => "table table-bordered", "border" => "1"] : $meta['params'];
|
$params = empty($meta['params']) ? ["class" => "table table-bordered", "border" => "1"] : $meta['params'];
|
||||||
if ($meta) {
|
if ($meta) {
|
||||||
$this->informationArray = [
|
$this->informationArray = [
|
||||||
"meta" => $meta,
|
"meta" => $meta,
|
||||||
|
"filters" => $filters,
|
||||||
"data" => $data ?? []
|
"data" => $data ?? []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -26,6 +27,7 @@ class JSONCreator
|
|||||||
{
|
{
|
||||||
if ($infArr)
|
if ($infArr)
|
||||||
return json_encode($infArr, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
return json_encode($infArr, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user