From eed654ce3c3eaaf509522841aab0896c966e225f Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Thu, 18 Apr 2024 10:23:11 +0200 Subject: [PATCH 1/6] refactor somecode to inertiatrait and buildpaginationlinks --- Docs/Documentation/CakePHP-Docker.md | 4 +- src/Traits/InertiaResponseTrait.php | 45 +++++++++++++++++--- templates/bake/element/Controller/add.twig | 28 ++---------- templates/bake/element/Controller/edit.twig | 25 +---------- templates/bake/element/Controller/index.twig | 10 +++-- 5 files changed, 51 insertions(+), 61 deletions(-) diff --git a/Docs/Documentation/CakePHP-Docker.md b/Docs/Documentation/CakePHP-Docker.md index 718f793..f0602d6 100644 --- a/Docs/Documentation/CakePHP-Docker.md +++ b/Docs/Documentation/CakePHP-Docker.md @@ -3,7 +3,7 @@ CakePHP installation and configuration example using Docker ``` -$> composer create-project --prefer-dist cakephp/app:~4.5 inertia_app +$> composer create-project --prefer-dist cakephp/app:~5.0 inertia_app $> cd inertia_app $> cp config/app_local.example.php config/app_local.php ``` @@ -49,4 +49,4 @@ launch container $> docker-compose up -d ``` -go to http://localhost:9099/ \ No newline at end of file +go to http://localhost:9099/ diff --git a/src/Traits/InertiaResponseTrait.php b/src/Traits/InertiaResponseTrait.php index a9ac4b9..b80cd31 100644 --- a/src/Traits/InertiaResponseTrait.php +++ b/src/Traits/InertiaResponseTrait.php @@ -16,6 +16,9 @@ use Cake\Event\EventInterface; use Cake\Core\InstanceConfigTrait; use Cake\Datasource\Paging\PaginatedInterface; +use Cake\I18n\Date; +use Cake\Routing\Router; +use Cake\Datasource\ConnectionManager; trait InertiaResponseTrait { @@ -30,10 +33,40 @@ trait InertiaResponseTrait 'JsonViewClass' => \CakeDC\Inertia\View\InertiaJsonView::class, ]; - public function buildPaginationLinks(PaginatedInterface $paging) + public function parseRelated(array $data, string $model): array + { + foreach ($data as $key => $val) { + if (is_array($val)) { + if (array_key_exists('_ids', $val)) { + $newItems = []; + foreach ($val as $item) { + foreach ($item as $value) { + $newItems[] = $value['id']; + } + } + $data[$key]['_ids'] = $newItems; + } + } + } + + $db = ConnectionManager::get('default'); + $collection = $db->getSchemaCollection(); + $tableSchema = $collection->describe($model); + foreach ($tableSchema->columns() as $column) { + if ($tableSchema->getColumnType($column) == 'timestampfractional' && $data[$column] !== null) { + $data[$column] = Date::parseDate($data[$column], 'YYYY-MM-dd'); + } + } + + return $data; + } + + public function buildPaginationLinks(PaginatedInterface $paging, string $controller, string $action) { $pagingParams = $paging->pagingParams(); $params = []; + $baseUrl = Router::url(['controller' => $controller, 'action' => $action]); + if (isset($pagingParams['sort'])) { $params[] = 'sort' . '=' . $pagingParams['sort']; } @@ -43,24 +76,24 @@ public function buildPaginationLinks(PaginatedInterface $paging) $params = implode('&', $params); if ($pagingParams['currentPage'] > 1) { - $links[] = ['url' => 'index?page=1' . $params, 'label' => '<< ' . __('first')]; + $links[] = ['url' => $baseUrl . '?page=1' . $params, 'label' => '<< ' . __('first')]; } if ($pagingParams['hasPrevPage']) { $links[] = [ - 'url' => 'index?page=' . ($pagingParams['currentPage'] - 1) . $params, + 'url' => $baseUrl . '?page=' . ($pagingParams['currentPage'] - 1) . $params, 'label' => '< ' . __('previous')]; } for ($i = 1; $i <= $pagingParams['pageCount']; $i++) { - $links[] = ['url' => 'index?page=' . $i . $params, 'label' => $i]; + $links[] = ['url' => $baseUrl . '?page=' . $i . $params, 'label' => $i]; } if ($pagingParams['hasNextPage']) { $links[] = [ - 'url' => 'index?page=' . ($pagingParams['currentPage'] + 1) . $params, + 'url' => $baseUrl . '?page=' . ($pagingParams['currentPage'] + 1) . $params, 'label' => __('next') . ' >']; } if ($pagingParams['currentPage'] < $pagingParams['pageCount']) { $links[] = [ - 'url' => 'index?page=' . $pagingParams['pageCount'] . $params, + 'url' => $baseUrl . '?page=' . $pagingParams['pageCount'] . $params, 'label' => __('last') . ' >>']; } diff --git a/templates/bake/element/Controller/add.twig b/templates/bake/element/Controller/add.twig index 122814e..0612fd4 100644 --- a/templates/bake/element/Controller/add.twig +++ b/templates/bake/element/Controller/add.twig @@ -19,31 +19,9 @@ { $errors = []; ${{ singularName }} = $this->{{ currentModelName }}->newEmptyEntity(); - if ($this->request->is('post')) { - $data = $this->request->getData(); - - foreach ($data as $key => $val) { - if (is_array($val)) { - if (array_key_exists('_ids', $val)) { - $newItems = []; - foreach ($val as $item) { - foreach ($item as $value) { - $newItems[] = $value['id']; - } - } - $data[$key]['_ids'] = $newItems; - } - } - } - - $db = \Cake\Datasource\ConnectionManager::get('default'); - $collection = $db->getSchemaCollection(); - $tableSchema = $collection->describe('{{pluralHumanName}}'); - foreach ($tableSchema->columns() as $column) { - if ($tableSchema->getColumnType($column) == 'timestampfractional' && $data[$column] !== null) { - $data[$column] = \Cake\I18n\FrozenDate::parseDate($data[$column], 'YYYY-MM-dd'); - } - } + if ($this->getRequest()->is('post')) { + $data = $this->getRequest()->getData(); + $data = $this->parseRelated($data, '{{ pluralName }}'); ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/Controller/edit.twig b/templates/bake/element/Controller/edit.twig index 4280c29..7cd3a88 100644 --- a/templates/bake/element/Controller/edit.twig +++ b/templates/bake/element/Controller/edit.twig @@ -27,30 +27,7 @@ ]); if ($this->request->is(['patch', 'post', 'put'])) { $data = $this->request->getData(); - - foreach ($data as $key => $val) { - if (is_array($val)) { - if (array_key_exists('_ids', $val)) { - $newItems = []; - foreach ($val as $item) { - foreach ($item as $value) { - $newItems[] = $value['id']; - } - } - $data[$key]['_ids'] = $newItems; - } - } - } - - $db = \Cake\Datasource\ConnectionManager::get('default'); - $collection = $db->getSchemaCollection(); - $tableSchema = $collection->describe('{{pluralHumanName}}'); - foreach ($tableSchema->columns() as $column) { - if ($tableSchema->getColumnType($column) == 'timestampfractional') { - $data[$column] = \Cake\I18n\FrozenDate::parseDate($data[$column], 'YYYY-MM-dd'); - } - } - + $data = $this->parseRelated($data, '{{ pluralName }}'); ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/Controller/index.twig b/templates/bake/element/Controller/index.twig index f729131..f0f30c0 100644 --- a/templates/bake/element/Controller/index.twig +++ b/templates/bake/element/Controller/index.twig @@ -17,21 +17,23 @@ public function index() { {% set belongsTo = Bake.aliasExtractor(modelObj, 'BelongsTo') %} -{% if belongsTo %} $settings = [ 'limit' => 1, 'finder' => 'withRelated', ]; -{% endif %} $paginator = new NumericPaginator(); - $pages = $paginator->paginate( + ${{ pluralName }} = $paginator->paginate( $this->fetchTable('{{ currentModelName }}'), $this->request->getQueryParams(), $settings ); - $links = $this->buildPaginationLinks(${{ pluralName }}); + $links = $this->buildPaginationLinks( + ${{ pluralName }}, + $this->getRequest()->getParam('controller'), + $this->getRequest()->getParam('action') + ); $this->set(compact('{{ pluralName }}', 'links')); } From f52518b9b739ea5562e4fbab9e35590028d24976 Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Thu, 25 Apr 2024 11:27:52 +0200 Subject: [PATCH 2/6] replace require with import to adapt to ES6 --- resources/js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/app.js b/resources/js/app.js index 390cb6d..97b543a 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -3,7 +3,7 @@ import { createInertiaApp } from '@inertiajs/vue3' createInertiaApp({ title: title => title ? `${title} - Vue App` : 'Vue App', - resolve: (name) => require(`./Components/${name}.vue`), + resolve: name => import(`./Components/${name}`), setup({ el, App, props, plugin }) { return createApp({ render: () => h(App, props) }) .use(plugin) From 5898b682b5faea5dd06e2d1c073b58b6514d6641 Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Thu, 25 Apr 2024 13:59:37 +0200 Subject: [PATCH 3/6] parse belongsToMany values before post on vue, fix some vue warns, change parseRelated to adjustDate and check columntype from schema related to entity instead of connectionmanager --- resources/webpack.config.js | 8 +++++++ src/Traits/InertiaResponseTrait.php | 24 ++++----------------- templates/bake/Template/index.twig | 6 +++--- templates/bake/Template/view.twig | 2 +- templates/bake/element/Controller/add.twig | 3 +-- templates/bake/element/Controller/edit.twig | 3 +-- templates/bake/element/form.twig | 21 ++++++++++++------ 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/resources/webpack.config.js b/resources/webpack.config.js index 5521c27..65ac9cf 100644 --- a/resources/webpack.config.js +++ b/resources/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack'); module.exports = { output: { chunkFilename: 'js/[name].js?id=[chunkhash]' }, @@ -11,4 +12,11 @@ module.exports = { devServer: { allowedHosts: 'all', }, + plugins: [ + new webpack.DefinePlugin({ + __VUE_OPTIONS_API__: 'true', + __VUE_PROD_DEVTOOLS__: 'false', + __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false' + }), + ] } diff --git a/src/Traits/InertiaResponseTrait.php b/src/Traits/InertiaResponseTrait.php index b80cd31..d915340 100644 --- a/src/Traits/InertiaResponseTrait.php +++ b/src/Traits/InertiaResponseTrait.php @@ -33,27 +33,11 @@ trait InertiaResponseTrait 'JsonViewClass' => \CakeDC\Inertia\View\InertiaJsonView::class, ]; - public function parseRelated(array $data, string $model): array + public function adjustDate(array $data, string $model): array { - foreach ($data as $key => $val) { - if (is_array($val)) { - if (array_key_exists('_ids', $val)) { - $newItems = []; - foreach ($val as $item) { - foreach ($item as $value) { - $newItems[] = $value['id']; - } - } - $data[$key]['_ids'] = $newItems; - } - } - } - - $db = ConnectionManager::get('default'); - $collection = $db->getSchemaCollection(); - $tableSchema = $collection->describe($model); - foreach ($tableSchema->columns() as $column) { - if ($tableSchema->getColumnType($column) == 'timestampfractional' && $data[$column] !== null) { + $model = $this->fetchTable($model); + foreach ($model->getSchema()->columns() as $column) { + if ($model->getSchema()->getColumnType($column) === 'timestampfractional' && $data[$column] !== null) { $data[$column] = Date::parseDate($data[$column], 'YYYY-MM-dd'); } } diff --git a/templates/bake/Template/index.twig b/templates/bake/Template/index.twig index cc26889..fa5f519 100644 --- a/templates/bake/Template/index.twig +++ b/templates/bake/Template/index.twig @@ -17,11 +17,11 @@ const props = defineProps({ csrfToken: String, - flash: [], - {{ pluralVar }}: [], + flash: Array|Object, + {{ pluralVar }}: Array|Object, sort: String, direction: String, - links: [], + links: Array|Object, }) const direction = ref(0) diff --git a/templates/bake/Template/view.twig b/templates/bake/Template/view.twig index 21875d3..d8b37f4 100644 --- a/templates/bake/Template/view.twig +++ b/templates/bake/Template/view.twig @@ -27,7 +27,7 @@ const props = defineProps({ csrfToken: String, - {{singularVar}}: [], + {{singularVar}}: Array|Object, }) function formatDate(date) { diff --git a/templates/bake/element/Controller/add.twig b/templates/bake/element/Controller/add.twig index 0612fd4..0dd71a7 100644 --- a/templates/bake/element/Controller/add.twig +++ b/templates/bake/element/Controller/add.twig @@ -20,8 +20,7 @@ $errors = []; ${{ singularName }} = $this->{{ currentModelName }}->newEmptyEntity(); if ($this->getRequest()->is('post')) { - $data = $this->getRequest()->getData(); - $data = $this->parseRelated($data, '{{ pluralName }}'); + $data = $this->adjustDate($this->getRequest()->getData(), '{{ currentModelName }}'); ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/Controller/edit.twig b/templates/bake/element/Controller/edit.twig index 7cd3a88..c7d1f8d 100644 --- a/templates/bake/element/Controller/edit.twig +++ b/templates/bake/element/Controller/edit.twig @@ -26,8 +26,7 @@ 'contain' => {{ Bake.exportArray(belongsToMany)|raw }}, ]); if ($this->request->is(['patch', 'post', 'put'])) { - $data = $this->request->getData(); - $data = $this->parseRelated($data, '{{ pluralName }}'); + $data = $this->adjustDate($this->getRequest()->getData(), '{{ currentModelName }}'); ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/form.twig b/templates/bake/element/form.twig index 8d928c0..a3e2aaf 100644 --- a/templates/bake/element/form.twig +++ b/templates/bake/element/form.twig @@ -19,19 +19,19 @@ const props = defineProps({ csrfToken: String, - flash: [], - {{singularVar}}: [], - errors: [],{{- "\n" }} + flash: Array|Object, + {{singularVar}}: Array|Object, + errors: Array|Object,{{- "\n" }} {%- for field in fields %} {%- if field not in primaryKey %} {%- if keyFields[field] is defined %} - {{ keyFields[field] }}: [], + {{ keyFields[field] }}: Array|Object, {%- endif %} {%- endif %} {%- endfor %} {%- if associations.BelongsToMany is defined %} {%- for assocName, assocData in associations.BelongsToMany %} - {{- "\n" }} options_{{ assocData.property }}: [], + {{- "\n" }} options_{{ assocData.property }}: Array|Object, {%- endfor %} {%- endif %} {{- "\n" }} }) @@ -77,6 +77,15 @@ }) function submit() { +{{- "\n" }} +{%- if associations.BelongsToMany is defined %} + {%- for assocName, assocData in associations.BelongsToMany %} + let {{ assocData.property }}Values = []; + for (let key in form.{{ assocData.property }}){ + {{ assocData.property }}Values.push(form.{{ assocData.property }}[key].id); + } + {%- endfor %} + {%- endif %} {{- "\n" }} {%- if prefix == '' %} let postUrl = '/{{ pluralVar }}/{{ action }}'; @@ -98,7 +107,7 @@ {%- if associations.BelongsToMany is defined %} {%- for assocName, assocData in associations.BelongsToMany %} {{ assocData.property }}: { - _ids : form.{{ assocData.property }} + _ids : {{ assocData.property }}Values }{{- "\n" }} {%- endfor %} {%- endif %} From a2d68d7dc97a4dcbf43c4c983b4c90ec0409279f Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Thu, 25 Apr 2024 14:03:28 +0200 Subject: [PATCH 4/6] remove unused ConnectionManager --- src/Traits/InertiaResponseTrait.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/InertiaResponseTrait.php b/src/Traits/InertiaResponseTrait.php index d915340..6d88997 100644 --- a/src/Traits/InertiaResponseTrait.php +++ b/src/Traits/InertiaResponseTrait.php @@ -18,7 +18,6 @@ use Cake\Datasource\Paging\PaginatedInterface; use Cake\I18n\Date; use Cake\Routing\Router; -use Cake\Datasource\ConnectionManager; trait InertiaResponseTrait { From 0ebff5ce1b3eac7a972efc8057993ada52dfb093 Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Wed, 1 May 2024 08:56:22 +0200 Subject: [PATCH 5/6] resolve problem with date --- config/sql/example(postgresql).psql | 2 +- src/Traits/InertiaResponseTrait.php | 3 ++- templates/bake/Model/table.twig | 19 +++++++++++++++++++ templates/bake/element/Controller/add.twig | 3 +-- templates/bake/element/Controller/edit.twig | 3 +-- templates/bake/element/form.twig | 9 +++++++-- 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/config/sql/example(postgresql).psql b/config/sql/example(postgresql).psql index 5086d03..4cd7f59 100644 --- a/config/sql/example(postgresql).psql +++ b/config/sql/example(postgresql).psql @@ -26,7 +26,7 @@ CREATE TABLE public.pages ( created timestamp NOT NULL, modified timestamp NOT NULL, category_id int4 NULL, - published_date timestamp NULL, + published_date date NULL, CONSTRAINT pages_pkey PRIMARY KEY (id) ); diff --git a/src/Traits/InertiaResponseTrait.php b/src/Traits/InertiaResponseTrait.php index 6d88997..d8ce6e7 100644 --- a/src/Traits/InertiaResponseTrait.php +++ b/src/Traits/InertiaResponseTrait.php @@ -34,13 +34,14 @@ trait InertiaResponseTrait public function adjustDate(array $data, string $model): array { + /* $model = $this->fetchTable($model); foreach ($model->getSchema()->columns() as $column) { if ($model->getSchema()->getColumnType($column) === 'timestampfractional' && $data[$column] !== null) { $data[$column] = Date::parseDate($data[$column], 'YYYY-MM-dd'); } } - + */ return $data; } diff --git a/templates/bake/Model/table.twig b/templates/bake/Model/table.twig index 6c12df6..5f96685 100644 --- a/templates/bake/Model/table.twig +++ b/templates/bake/Model/table.twig @@ -19,6 +19,8 @@ namespace: fileBuilder.namespace, classImports: fileBuilder.classImports(['Cake\\ORM\\Query\\SelectQuery', 'Cake\\ORM\\RulesChecker', 'Cake\\ORM\\Table', 'Cake\\Validation\\Validator']), }) }} +use ArrayObject; +use Cake\Event\EventInterface; {{ DocBlock.classDescription(name, 'Model', annotations)|raw }} class {{ name }}Table extends Table{{ fileBuilder.classBuilder.implements ? ' implements ' ~ fileBuilder.classBuilder.implements|join(', ') : '' }} @@ -188,4 +190,21 @@ class {{ name }}Table extends Table{{ fileBuilder.classBuilder.implements ? ' im return $query; } + + /** + * Parse date fields before patch entity + * + * @param \Cake\Event\EventInterface $event + * @param \ArrayObject $data + * @param \ArrayObject $options + * @return void + */ + public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void + { + foreach ($this->getSchema()->columns() as $column) { + if ($this->getSchema()->getColumnType($column) === 'timestampfractional' && $data[$column] !== null) { + $data[$column] = Date::parseDate($data[$column], 'YYYY-MM-dd'); + } + } + } } diff --git a/templates/bake/element/Controller/add.twig b/templates/bake/element/Controller/add.twig index 0dd71a7..30929c0 100644 --- a/templates/bake/element/Controller/add.twig +++ b/templates/bake/element/Controller/add.twig @@ -20,8 +20,7 @@ $errors = []; ${{ singularName }} = $this->{{ currentModelName }}->newEmptyEntity(); if ($this->getRequest()->is('post')) { - $data = $this->adjustDate($this->getRequest()->getData(), '{{ currentModelName }}'); - ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); + ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $this->getRequest()->getData()); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/Controller/edit.twig b/templates/bake/element/Controller/edit.twig index c7d1f8d..8fd4f8d 100644 --- a/templates/bake/element/Controller/edit.twig +++ b/templates/bake/element/Controller/edit.twig @@ -26,8 +26,7 @@ 'contain' => {{ Bake.exportArray(belongsToMany)|raw }}, ]); if ($this->request->is(['patch', 'post', 'put'])) { - $data = $this->adjustDate($this->getRequest()->getData(), '{{ currentModelName }}'); - ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $data); + ${{ singularName }} = $this->{{ currentModelName }}->patchEntity(${{ singularName }}, $this->getRequest()->getData()); if ($this->{{ currentModelName }}->save(${{ singularName }})) { $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.')); diff --git a/templates/bake/element/form.twig b/templates/bake/element/form.twig index a3e2aaf..75b2034 100644 --- a/templates/bake/element/form.twig +++ b/templates/bake/element/form.twig @@ -16,6 +16,7 @@ import { VueEditor } from "vue3-editor"; import Datepicker from 'vue3-datepicker'; import Multiselect from '@vueform/multiselect' + import moment from 'moment' const props = defineProps({ csrfToken: String, @@ -100,10 +101,14 @@ {{- "\n" }} {%- for field in fields %} {%- if field not in primaryKey %} - {{field}} : form.{{field}},{{- "\n" }} + {%- set fieldData = Bake.columnData(field, schema) %} + {%- if fieldData.type in ['date', 'timestampfractional'] and fieldData.null %} + {{field}} : form.{{field}} !== null ? moment(form.{{field}}.toString()).format("YYYY-MM-DD") : '',{{- "\n" }} + {%- else %} + {{field}} : form.{{field}},{{- "\n" }} + {%- endif %} {%- endif %} {%- endfor %} - {%- if associations.BelongsToMany is defined %} {%- for assocName, assocData in associations.BelongsToMany %} {{ assocData.property }}: { From 252b69cf2e73a0c4678144dfaf881b33009bf83a Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Wed, 1 May 2024 08:58:14 +0200 Subject: [PATCH 6/6] remove function adjustDate --- src/Traits/InertiaResponseTrait.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Traits/InertiaResponseTrait.php b/src/Traits/InertiaResponseTrait.php index d8ce6e7..490bd02 100644 --- a/src/Traits/InertiaResponseTrait.php +++ b/src/Traits/InertiaResponseTrait.php @@ -32,19 +32,6 @@ trait InertiaResponseTrait 'JsonViewClass' => \CakeDC\Inertia\View\InertiaJsonView::class, ]; - public function adjustDate(array $data, string $model): array - { - /* - $model = $this->fetchTable($model); - foreach ($model->getSchema()->columns() as $column) { - if ($model->getSchema()->getColumnType($column) === 'timestampfractional' && $data[$column] !== null) { - $data[$column] = Date::parseDate($data[$column], 'YYYY-MM-dd'); - } - } - */ - return $data; - } - public function buildPaginationLinks(PaginatedInterface $paging, string $controller, string $action) { $pagingParams = $paging->pagingParams();