init
parent
565dbd93ec
commit
4c4e6e7016
|
|
@ -116,7 +116,8 @@ class Page extends Model {
|
||||||
|
|
||||||
|
|
||||||
public static function byUrl($url) {
|
public static function byUrl($url) {
|
||||||
if ($url = trim($url, '/ ')) {
|
if ($url === '/') return Page::query()->where(['parent_id' => 0, 'slug' => ''])->first();
|
||||||
|
elseif ($url = trim($url, '/ ')) {
|
||||||
$query = self::query();
|
$query = self::query();
|
||||||
collect(explode('/', $url))->reverse()->values()->each(function($slug, $index) use($query) {
|
collect(explode('/', $url))->reverse()->values()->each(function($slug, $index) use($query) {
|
||||||
if ($slug !== '') {
|
if ($slug !== '') {
|
||||||
|
|
@ -163,4 +164,8 @@ class Page extends Model {
|
||||||
return self::query()->where(['parent_id' => 0])->orderBy('ord')->get();
|
return self::query()->where(['parent_id' => 0])->orderBy('ord')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function main() {
|
||||||
|
return self::query()->firstOrCreate(['parent_id' => -1]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ class PageType {
|
||||||
public const PUBLICATIONS = 'publications';
|
public const PUBLICATIONS = 'publications';
|
||||||
public const REGISTRY = 'registry';
|
public const REGISTRY = 'registry';
|
||||||
public const TK_STRUCTURE = 'tk-structure';
|
public const TK_STRUCTURE = 'tk-structure';
|
||||||
|
public const NAV_PAGE = 'nav-page';
|
||||||
|
|
||||||
public const TITLES = [
|
public const TITLES = [
|
||||||
self::CONTENT => 'Контентная страница',
|
self::CONTENT => 'Контентная страница',
|
||||||
self::PUBLICATIONS => 'Страница публикаций',
|
self::PUBLICATIONS => 'Страница публикаций',
|
||||||
self::REGISTRY => 'Страница реестра',
|
self::REGISTRY => 'Страница реестра',
|
||||||
self::TK_STRUCTURE => 'Структура ТК'
|
self::TK_STRUCTURE => 'Структура ТК',
|
||||||
|
self::NAV_PAGE => 'Страница навигации (без контента)'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
"eduarguz/shift-php-cs": "dev-master",
|
"eduarguz/shift-php-cs": "dev-master",
|
||||||
"facade/ignition": "^2.5",
|
"facade/ignition": "^2.5",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.37",
|
||||||
"mockery/mockery": "^1.4.2",
|
"mockery/mockery": "^1.4.2",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^5.0",
|
||||||
"phpunit/phpunit": "^9.3.3"
|
"phpunit/phpunit": "^9.3.3"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Database\Seeders\Pages;
|
namespace Database\Seeders\Pages;
|
||||||
|
|
||||||
use App\Models\Pages\Page;
|
use App\Models\Pages\Page;
|
||||||
use App\Models\Pages\PageSubType;
|
|
||||||
use App\Models\Pages\PageType;
|
use App\Models\Pages\PageType;
|
||||||
use App\Models\Registries\RegistryType;
|
use App\Models\Registries\RegistryType;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
@ -11,134 +10,53 @@ use Illuminate\Support\Str;
|
||||||
|
|
||||||
class PagesTableSeeder extends Seeder {
|
class PagesTableSeeder extends Seeder {
|
||||||
public array $pages = [
|
public array $pages = [
|
||||||
'О центре' => [
|
'Главная' => [
|
||||||
|
'slug' => '',
|
||||||
'children' => [
|
'children' => [
|
||||||
'История' => [],
|
'Страница 1' => [
|
||||||
'Руководство' => [],
|
|
||||||
'Документы' => [
|
|
||||||
'children' => [
|
'children' => [
|
||||||
'Документы об учреждении' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
'Подстраница 1' => [],
|
||||||
'Нормативные правовые акты' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
'Подстраница 2' => [],
|
||||||
'Наблюдательный совет' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
'Подстраница 3' => [],
|
||||||
'Государственное задание' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Закупки' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Бухгалтерская отчетность' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Антимонопольное законодательство' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Приказы Минстроя России' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Результаты специальной оценки труда' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE]
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Противодействие коррупции' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
'Страница 2' => [],
|
||||||
'Защита персональных данных' => [],
|
'Страница 3' => [],
|
||||||
'Охрана труда' => []
|
'Страница 4' => [],
|
||||||
|
'Страница 5' => []
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Деятельность' => [
|
'Main page' => [
|
||||||
|
'slug' => 'en',
|
||||||
'children' => [
|
'children' => [
|
||||||
'Оценка пригодности' => [
|
'page 1' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Реестр технических свидетельств' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::TECHNICAL_CERTIFICATES],
|
'subpage 1' => [],
|
||||||
'Заявка на оформление' => [],
|
'subpage 2' => [],
|
||||||
'Консультационные услуги' => [],
|
'subpage 3' => []
|
||||||
]
|
|
||||||
],
|
|
||||||
'ТК 465 «Строительство»' => [
|
|
||||||
'children' => [
|
|
||||||
'Руководство' => [],
|
|
||||||
'Структура' => ['type' => PageType::TK_STRUCTURE],
|
|
||||||
'Состав' => [],
|
|
||||||
'Документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'АИС ТК 465 «Строительство»' => []
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'Реестр требований ФЗ-63' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Нормирование и стандартизация' => [
|
|
||||||
'children' => [
|
|
||||||
'Реестр сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET],
|
|
||||||
'Реестр нормативно-технической документации' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::NTD],
|
|
||||||
'Разработка сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DEVELOPMENTS],
|
|
||||||
'Прикладные исследования' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RESEARCHES],
|
|
||||||
'Методические материалы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'Международная деятельность' => [
|
|
||||||
'children' => [
|
|
||||||
'ISO' => [],
|
|
||||||
'МТК 465 «Строительство»' => [],
|
|
||||||
'Межправительственный совет' => [],
|
|
||||||
'Базовая организация СНГ' => [],
|
|
||||||
'Разработка ТР ЕАЭС' => [],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'СТУ' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'КСИ' => [],
|
|
||||||
'Добровольная сертификация' => [
|
|
||||||
'children' => [
|
|
||||||
'О системе' => [],
|
|
||||||
'Основополагающие документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED],
|
|
||||||
'Решения ЦОС' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
|
||||||
'Руководящие документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
|
||||||
'Реестр органов по сертификации' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFIERS],
|
|
||||||
'Реестр испытательных лабораторий' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::LABORATORIES],
|
|
||||||
'Реестр экспертов' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::EXPERTS],
|
|
||||||
'Реестр сертификатов соответствия' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CERTIFICATES],
|
|
||||||
'Бланки документов' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE],
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'page 2' => [],
|
||||||
|
'page 3' => [],
|
||||||
|
'page 4' => [],
|
||||||
|
'page 5' => []
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Услуги' => [
|
'Головна сторінка' => [
|
||||||
|
'slug' => 'ua',
|
||||||
'children' => [
|
'children' => [
|
||||||
'Технические свидетельства' => [
|
'Сторінка 1' => [
|
||||||
'children' => [
|
'children' => [
|
||||||
'Консалтинговые услуги ТС' => [],
|
'Підсторінка 1' => [],
|
||||||
|
'Підсторінка 2' => [],
|
||||||
|
'Підсторінка 3' => []
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'Консалтинг' => [
|
'Сторінка 2' => [],
|
||||||
'children' => [
|
'Сторінка 3' => [],
|
||||||
'Экспертиза тех регулирования' => [],
|
'Сторінка 4' => [],
|
||||||
'Разработка нормативных документов' => [],
|
'Сторінка 5' => []
|
||||||
'Нормативный консалтинг' => [],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'Портфолио проектов' => [
|
|
||||||
'type' => PageType::PUBLICATIONS,
|
|
||||||
'sub_type' => PageSubType::PUBLICATION_PORTFOLIO
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
],
|
|
||||||
'Пресс-центр' => [
|
|
||||||
'children' => [
|
|
||||||
'Новости' => [
|
|
||||||
'type' => PageType::PUBLICATIONS,
|
|
||||||
'sub_type' => PageSubType::PUBLICATION_NEWS
|
|
||||||
],
|
|
||||||
'Медиа' => [
|
|
||||||
'children' => [
|
|
||||||
'Фотогалерея' => [
|
|
||||||
'type' => PageType::PUBLICATIONS,
|
|
||||||
'sub_type' => PageSubType::PUBLICATION_PHOTOS
|
|
||||||
],
|
|
||||||
'Видеоархив' => [
|
|
||||||
'type' => PageType::PUBLICATIONS,
|
|
||||||
'sub_type' => PageSubType::PUBLICATION_VIDEO
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
// 'СМИ о нас' => [
|
|
||||||
// 'type' => PageType::PUBLICATIONS,
|
|
||||||
// 'sub_type' => PageSubType::PUBLICATION_SMI
|
|
||||||
// ],
|
|
||||||
'Контакты для СМИ' => [],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'Контакты' => [
|
|
||||||
// 'children' => [
|
|
||||||
// 'Контактные данные' => [],
|
|
||||||
// 'Как добраться' => [],
|
|
||||||
// 'Консультации' => [],
|
|
||||||
// 'Обратная связь' => [],
|
|
||||||
// ]
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -153,13 +71,13 @@ class PagesTableSeeder extends Seeder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importPage($name, $data, ?Page $parent = null) {
|
public function importPage($name, $data, ?Page $parent = null) {
|
||||||
$slug = Str::slug(Str::transliterate($name));
|
$slug = array_key_exists('slug', $data) ? $data['slug'] : Str::slug(Str::transliterate($name));
|
||||||
$data += ['type' => $data['type'] ?? PageType::CONTENT, 'name' => $name];
|
$data += ['type' => $data['type'] ?? PageType::CONTENT, 'name' => $name];
|
||||||
$page = Page::firstOrCreate(['parent_id' => $parent->id ?? 0, 'slug' => $slug]);
|
$page = Page::firstOrCreate(['parent_id' => $parent->id ?? 0, 'slug' => $slug]);
|
||||||
if ($v = collect($data)->except('children', 'registry_type')->all()) $page->update($v);
|
if ($v = collect($data)->except('children', 'registry_type')->all()) $page->update($v);
|
||||||
if ($page->type === PageType::REGISTRY) $page->registry->update(['type' => $data['registry_type'] ?? RegistryType::SIMPLE]);
|
if ($page->type === PageType::REGISTRY) $page->registry->update(['type' => $data['registry_type'] ?? RegistryType::SIMPLE]);
|
||||||
$ord = 0;
|
$ord = 0;
|
||||||
collect($data['children'] ?? [])->each(function ($data, $name) use ($page, &$ord) {
|
collect($data['children'] ?? [])->each(function($data, $name) use($page, &$ord) {
|
||||||
$data['ord'] = $ord++;
|
$data['ord'] = $ord++;
|
||||||
$this->importPage($name, $data, $page);
|
$this->importPage($name, $data, $page);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue