- ExportPageAction: exports page with SEO and section path as JSON
- ImportPageAction: imports page from JSON, resolves section by slug path
- PageController: export/download and import endpoints
- Routes: GET /{page}/export, POST /import
- Index.vue: export button per row, import button in header (local only)
- Import restricted to APP_ENV=local (backend + frontend check)
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Containers\Dashboard\Actions\Pages;
|
|
|
|
use App\Containers\AppStructure\Models\Page;
|
|
|
|
class ExportPageAction
|
|
{
|
|
public function run(Page $page): array
|
|
{
|
|
$page->load(['section.mainSection', 'seo']);
|
|
|
|
$sectionPath = null;
|
|
|
|
if ($page->section) {
|
|
$sectionPath = [
|
|
'main_section_slug' => $page->section->mainSection?->slug,
|
|
'sub_section_slug' => $page->section->slug,
|
|
];
|
|
}
|
|
|
|
return [
|
|
'export_version' => 1,
|
|
'exported_at' => now()->toIso8601String(),
|
|
'page' => [
|
|
'title' => $page->title,
|
|
'slug' => $page->slug,
|
|
'code' => $page->code,
|
|
'content' => $page->content,
|
|
'settings' => $page->settings,
|
|
'searchable' => $page->searchable,
|
|
'sort' => $page->sort,
|
|
'is_visible' => $page->is_visible,
|
|
],
|
|
'seo' => $page->seo ? [
|
|
'title' => $page->seo->title,
|
|
'description' => $page->seo->description,
|
|
] : null,
|
|
'section_path' => $sectionPath,
|
|
];
|
|
}
|
|
}
|