Skip to content

Commit

Permalink
feat: use file instead of database
Browse files Browse the repository at this point in the history
  • Loading branch information
keeama13 authored and 64knl committed Nov 28, 2023
1 parent 18b14cd commit fb3ee10
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Http/Controllers/CmsEditor/CmsEditorTableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,19 @@ public function readOne(Table $table)

$widget1 = new LayoutWidget($table->name ?? 'New table', 6);

$tableConfigFile = base_path('resources/siteboss/tables/'.$table->table.'.json');
$form = new LayoutForm('/app/editor/table/'.$table->id);

if (file_exists($tableConfigFile)) {
$table = (object) json_decode(file_get_contents($tableConfigFile))[0];
$tables = $table->items;
usort($tables, function ($item1, $item2) {
return $item1->order <=> $item2->order;
});
} else {
$tables = $table->items()->orderBy('order', 'asc')->get();
}

$form->addInput((new LayoutInputText('name', 'Name'))->setValue($table->name ?? '')->setRequired());
$form->addInput((new LayoutInputText('table', 'Table'))->setValue($table->table ?? '')->setRequired());

Expand Down Expand Up @@ -164,7 +175,6 @@ public function readOne(Table $table)
$UItable->addHeader(new LayoutTableHeader('Type', 'type'));
$UItable->addHeader(new LayoutTableHeader('Error', 'error'));
$UItable->addHeader(new LayoutTableHeader('Enabled', 'enabled'));
$tables = $table->items()->orderBy('order', 'asc')->get();

foreach ($tables as $cmsTable) {
$row = new LayoutTableRow($cmsTable->id, '/app/editor/table/'.$table->id.'/'.$cmsTable->id);
Expand Down

0 comments on commit fb3ee10

Please sign in to comment.