user crud
This commit is contained in:
@ -15,7 +15,8 @@ class JSONCreator
|
||||
if ($meta && $data) {
|
||||
$this->informationArray = [
|
||||
"meta" => [
|
||||
"columns" => $meta['columns'],
|
||||
"columns" => $meta['columns'] ?? [],
|
||||
"rows" => $meta['rows'] ?? [],
|
||||
"perPage" => $meta['perPage'] ?? 10,
|
||||
"currentPage" => $meta['currentPage'] ?? 1,
|
||||
"baseUrl" => $meta['baseUrl'] ?? '',
|
||||
|
29
kernel/IGTabel/ViewJsonTableEloquentModel.php
Normal file
29
kernel/IGTabel/ViewJsonTableEloquentModel.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\IGTabel;
|
||||
|
||||
use app\helpers\Debug;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ViewJsonTableEloquentModel
|
||||
{
|
||||
private string|null $jsonStr;
|
||||
|
||||
private array $meta = [];
|
||||
|
||||
public function __construct(Model $model, array $params = [])
|
||||
{
|
||||
$this->meta['rows'] = $params['rows'] ?? $model->labels();
|
||||
$this->meta['baseUrl'] = $params['baseUrl'] ?? $model->table;
|
||||
$this->meta['params'] = $params['params'] ?? [];
|
||||
$this->meta['actions'] = $params['actions'] ?? [];
|
||||
|
||||
$this->jsonStr = (new JSONCreator($this->meta, $model->toArray()))->getJson();
|
||||
}
|
||||
|
||||
public function getJson(): ?string
|
||||
{
|
||||
return $this->jsonStr;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user