From 31d28c605b6db84dd4bb441d8fc90155a42207fe Mon Sep 17 00:00:00 2001 From: panabonic Date: Fri, 10 Nov 2023 12:56:32 +0300 Subject: [PATCH] few updates --- .../Api/Assets/UploadFileController.php | 2 +- app/Models/Asset.php | 3 +- app/Models/Pages/Page.php | 4 - database/seeders/Pages/PagesTableSeeder.php | 92 +++++++++++++------ public/storage/.gitignore | 2 + 5 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 public/storage/.gitignore diff --git a/app/Http/Controllers/Api/Assets/UploadFileController.php b/app/Http/Controllers/Api/Assets/UploadFileController.php index fd8e173..f1dba2b 100644 --- a/app/Http/Controllers/Api/Assets/UploadFileController.php +++ b/app/Http/Controllers/Api/Assets/UploadFileController.php @@ -146,7 +146,7 @@ class UploadFileController extends Controller { protected function storeInFileSystem(array $attributes): string { $filename = md5(Str::random(16).date('U')); - $path = "upload/{$filename[0]}/$filename.{$this->validMimes[$attributes['mime']]['extension']}"; + $path = "public/upload/{$filename[0]}/$filename.{$this->validMimes[$attributes['mime']]['extension']}"; Storage::put($path, $attributes['content']); return $path; } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index d47d763..8c9a03d 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -29,7 +29,8 @@ class Asset extends Model { { $result = [ 'open' => asset("/api/assets/{$this->uuid}"), - 'download' => asset("/api/assets/{$this->uuid}/download") + 'download' => asset("/api/assets/{$this->uuid}/download"), + 'direct' => asset("storage/{$this->path}") ]; if ($this->type == 'image') { $result['full'] = asset("/api/assets/{$this->uuid}/render"); diff --git a/app/Models/Pages/Page.php b/app/Models/Pages/Page.php index 045cbcc..d8e785a 100644 --- a/app/Models/Pages/Page.php +++ b/app/Models/Pages/Page.php @@ -172,8 +172,4 @@ class Page extends Model { return self::query()->where(['parent_id' => 0])->orderBy('ord')->get(); } - public static function main() { - return self::query()->firstOrCreate(['parent_id' => -1]); - } - } diff --git a/database/seeders/Pages/PagesTableSeeder.php b/database/seeders/Pages/PagesTableSeeder.php index 75a4e82..2cd9d77 100644 --- a/database/seeders/Pages/PagesTableSeeder.php +++ b/database/seeders/Pages/PagesTableSeeder.php @@ -4,6 +4,7 @@ namespace Database\Seeders\Pages; use App\Models\Pages\Page; use App\Models\Pages\PageType; +use App\Models\Publications\PublicationType; use App\Models\Registries\RegistryType; use Illuminate\Database\Seeder; use Illuminate\Support\Str; @@ -13,49 +14,82 @@ class PagesTableSeeder extends Seeder { 'Главная' => [ 'slug' => '', 'children' => [ - 'Страница 1' => [ + 'Контентная страница' => [ 'children' => [ - 'Подстраница 1' => [], - 'Подстраница 2' => [], - 'Подстраница 3' => [], + 'Пример 1' => [], + 'Пример 2' => [], + 'Пример 3' => [], ] ], - 'Страница 2' => [], - 'Страница 3' => [], - 'Страница 4' => [], - 'Страница 5' => [] + 'Реестры' => [ + 'type' => PageType::NAV_PAGE, + 'children' => [ + RegistryType::TITLES[RegistryType::SIMPLE] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], + RegistryType::TITLES[RegistryType::CATEGORIZED] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED], + RegistryType::TITLES[RegistryType::COMPANIES] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::COMPANIES], + RegistryType::TITLES[RegistryType::RULESET] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET], + RegistryType::TITLES[RegistryType::DEVELOPMENTS] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DEVELOPMENTS], + RegistryType::TITLES[RegistryType::TECHNICAL_CERTIFICATES] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::TECHNICAL_CERTIFICATES], + RegistryType::TITLES[RegistryType::NTD] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::NTD], + RegistryType::TITLES[RegistryType::RESEARCHES] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RESEARCHES], + RegistryType::TITLES[RegistryType::DISCUSSIONS] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DISCUSSIONS], + RegistryType::TITLES[RegistryType::CERTIFICATES] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFICATES], + RegistryType::TITLES[RegistryType::EXPERTS] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::EXPERTS], + RegistryType::TITLES[RegistryType::LABORATORIES] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::LABORATORIES], + RegistryType::TITLES[RegistryType::CERTIFIERS] => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFIERS], + ] + ], + 'Публикации' => [ + 'type' => PageType::NAV_PAGE, + 'children' => [ + PublicationType::TITLES[PublicationType::NEWS] => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::NEWS], + PublicationType::TITLES[PublicationType::PHOTOS] => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::PHOTOS], + PublicationType::TITLES[PublicationType::PORTFOLIO] => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::PORTFOLIO], + PublicationType::TITLES[PublicationType::SMI] => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::SMI], + PublicationType::TITLES[PublicationType::VIDEO] => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::VIDEO] + ] + ], + 'Структура ТК' => ['type' => PageType::TK_STRUCTURE] ] ], 'Main page' => [ 'slug' => 'en', 'children' => [ - 'page 1' => [ + 'Content page' => [ 'children' => [ - 'subpage 1' => [], - 'subpage 2' => [], - 'subpage 3' => [] + 'Example 1' => [], + 'Example 2' => [], + 'Example 3' => [] ] ], - 'page 2' => [], - 'page 3' => [], - 'page 4' => [], - 'page 5' => [] - ] - ], - 'Головна сторінка' => [ - 'slug' => 'ua', - 'children' => [ - 'Сторінка 1' => [ + 'Registries' => [ + 'type' => PageType::NAV_PAGE, 'children' => [ - 'Підсторінка 1' => [], - 'Підсторінка 2' => [], - 'Підсторінка 3' => [] + 'Simple registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], + 'Categorized registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED], + 'Companies registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::COMPANIES], + 'Ruleset registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET], + 'Developments registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DEVELOPMENTS], + 'Technical certificates registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::TECHNICAL_CERTIFICATES], + 'STD registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::NTD], + 'Researches registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RESEARCHES], + 'Public discussions registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DISCUSSIONS], + 'Certificates registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFICATES], + 'Experts registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::EXPERTS], + 'Laboratories registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::LABORATORIES], + 'Certification agencies registry' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFIERS], ] ], - 'Сторінка 2' => [], - 'Сторінка 3' => [], - 'Сторінка 4' => [], - 'Сторінка 5' => [] + 'Publications' => [ + 'type' => PageType::NAV_PAGE, + 'children' => [ + 'News' => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::NEWS], + 'Photo gallery' => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::PHOTOS], + 'Portfolio' => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::PORTFOLIO], + 'Mass media' => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::SMI], + 'Video' => ['type' => PageType::PUBLICATIONS, 'sub_type' => PublicationType::VIDEO] + ] + ] ] ] ]; diff --git a/public/storage/.gitignore b/public/storage/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/public/storage/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore