diff --git a/app/Models/Pages/PageSubType.php b/app/Models/Pages/PageSubType.php index 94491e2..8e45ddb 100644 --- a/app/Models/Pages/PageSubType.php +++ b/app/Models/Pages/PageSubType.php @@ -7,11 +7,13 @@ class PageSubType { public const PUBLICATION_SMI = 'publication-smi'; public const PUBLICATION_PHOTOS = 'publication-photos'; public const PUBLICATION_VIDEO = 'publication-video'; + public const PUBLICATION_PORTFOLIO = 'publication-portfolio'; public const TITLES = [ self::PUBLICATION_NEWS => 'Новость', self::PUBLICATION_SMI => 'СМИ о нас', self::PUBLICATION_PHOTOS => 'Фотогаллерея', self::PUBLICATION_VIDEO => 'Видеоархив', + self::PUBLICATION_PORTFOLIO => 'Портфолио' ]; } \ No newline at end of file diff --git a/app/Models/Publications/PublicationType.php b/app/Models/Publications/PublicationType.php index bf4e725..45deb1b 100644 --- a/app/Models/Publications/PublicationType.php +++ b/app/Models/Publications/PublicationType.php @@ -7,11 +7,13 @@ class PublicationType { public const SMI = 'smi'; public const PHOTOS = 'photos'; public const VIDEO = 'video'; + public const PORTFOLIO = 'portfolio'; public const TITLES = [ self::NEWS => 'Новость', self::SMI => 'СМИ о нас', self::PHOTOS => 'Фотогаллерея', self::VIDEO => 'Видеоархив', + self::PORTFOLIO => 'Портфолио', ]; } \ No newline at end of file diff --git a/app/Services/Forms/Publications/PublicationFormsServices.php b/app/Services/Forms/Publications/PublicationFormsServices.php index bc140a2..f50339e 100644 --- a/app/Services/Forms/Publications/PublicationFormsServices.php +++ b/app/Services/Forms/Publications/PublicationFormsServices.php @@ -8,5 +8,6 @@ class PublicationFormsServices { 'publication-smi' => PublicationSmiForms::class, 'publication-photos' => PublicationPhotosForms::class, 'publication-video' => PublicationVideoForms::class, + 'publication-portfolio' => PublicationPortfolioForms::class, ]; } diff --git a/app/Services/Forms/Publications/PublicationNewsForms.php b/app/Services/Forms/Publications/PublicationNewsForms.php index c88bbf2..16d8f21 100644 --- a/app/Services/Forms/Publications/PublicationNewsForms.php +++ b/app/Services/Forms/Publications/PublicationNewsForms.php @@ -27,7 +27,6 @@ class PublicationNewsForms extends FormsService { public function commonGroupFields(?Publication $model): array { $fields = [ - [ 'name' => 'published_at', 'title' => 'Дата публикации', diff --git a/app/Services/Forms/Publications/PublicationPortfolioForms.php b/app/Services/Forms/Publications/PublicationPortfolioForms.php new file mode 100644 index 0000000..55e97ad --- /dev/null +++ b/app/Services/Forms/Publications/PublicationPortfolioForms.php @@ -0,0 +1,120 @@ + 'Создание новой публикации в портфолио', 'update' => 'Редактирование публикации в портфолио']; + + public function form(?string $id = null, array $data = []): array { + $model = Publication::byUuid($id)->first(); + $groups = [ + ['name' => 'common', 'fields' => $this->commonGroupFields($model)] + ]; + return ['title' => $this->formTitle($model), 'data' => $groups]; + } + + public function commonGroupFields(?Publication $model): array { + + $params = $model->parsedParams ?? null; + + $fields = [ + [ + 'name' => 'name', + 'title' => 'Название компании', + 'type' => FieldType::STRING, + 'required' => true, + 'max_length' => 127, + 'value' => $model->name ?? null + ], + [ + 'name' => 'excerpt', + 'title' => 'Тип выполненных работ', + 'type' => FieldType::STRING, + 'required' => true, + 'value' => $model->excerpt ?? null + ], + [ + 'name' => 'description', + 'title' => 'Описание', + 'type' => FieldType::TEXT, + 'required' => true, + 'value' => $params->description ?? null + ], + [ + 'name' => 'poster_id', + 'title' => 'Превью', + 'type' => FieldType::IMAGE, + 'required' => true, + 'value' => ($model->poster ?? null) ? fractal($model->poster, new AssetTransformer()) : null + ], + ]; + return ['data' => $fields]; + } + + + public function store(array $data): ?JsonResponse { + $page = Page::byUuid($data['attach']['page_id'])->first(); + $pub = []; + $pub['page_id'] = $page->id; + $pub['author_id'] = Auth::user()->id; + $pub['type'] = PublicationType::PORTFOLIO; + $pub['name'] = $data['name']; + $pub['slug'] = Str::slug(Str::transliterate($data['name'])); + $pub['excerpt'] = $data['excerpt']; + $pub['published_at'] = now(); + if (empty($data['poster_id'])) { + $pub['poster_id'] = null; + } else { + $asset = Asset::query()->where(['uuid' => $data['poster_id']])->first(); + $pub['poster_id'] = $asset->id; + } + $params = []; + if (!empty($data['description'])) { + $params['description'] = $data['description']; + } + if (count($params) > 0) { + $pub['params'] = json_encode($params); + } + $model = Publication::create($pub, true); + return fractal($model, new PublicationTransformer())->respond(); + } + + public function update(string $id, array $data): ?JsonResponse { + $model = Publication::byUuid($id)->firstOrFail(); + $pub = []; + $pub['author_id'] = Auth::user()->id; + $pub['slug'] = Str::slug(Str::transliterate($data['name'])); + $pub['excerpt'] = $data['excerpt']; + if (!empty($data['name'])) { + $pub['name'] = $data['name']; + } + if (empty($data['poster_id'])) { + $pub['poster_id'] = null; + } else { + $asset = Asset::query()->where(['uuid' => $data['poster_id']])->first(); + $pub['poster_id'] = $asset->id; + } + $params = []; + if (!empty($data['description'])) { + $params['description'] = $data['description']; + } + if (count($params) > 0) { + $pub['params'] = json_encode($params); + } + $model->update($pub); + return fractal($model->fresh(), new PublicationTransformer())->respond(); + } +} diff --git a/app/Services/Forms/Publications/PublicationVideoForms.php b/app/Services/Forms/Publications/PublicationVideoForms.php index a1687b9..1360125 100644 --- a/app/Services/Forms/Publications/PublicationVideoForms.php +++ b/app/Services/Forms/Publications/PublicationVideoForms.php @@ -93,19 +93,26 @@ class PublicationVideoForms } public function formatUrl($url): string { - $videoId = ''; + $videoIdYoutube = ''; + $videoIdRutube = ''; $videoUrl = ''; switch (true) { case str_contains($url, $mask = 'https://youtu.be/'): case str_contains($url, $mask = 'https://www.youtube.com/watch?v='): - $videoId = str_replace($mask, '', $url); + $videoIdYoutube = str_replace($mask, '', $url); + break; + case str_contains($url, $mask = 'https://rutube.ru/video/'): + $videoIdRutube = str_replace($mask, '', $url); break; default: $videoUrl = $url; break; } - if ($videoId != '') { - $videoUrl = "https://www.youtube.com/embed/$videoId"; + if ($videoIdYoutube != '') { + $videoUrl = "https://www.youtube.com/embed/$videoIdYoutube"; + } + if ($videoIdRutube != '') { + $videoUrl = "https://rutube.ru/play/embed/$videoIdRutube"; } return $videoUrl; } diff --git a/database/seeders/Dictionaries/DictionariesTableSeeder.php b/database/seeders/Dictionaries/DictionariesTableSeeder.php index f5179cf..202b509 100644 --- a/database/seeders/Dictionaries/DictionariesTableSeeder.php +++ b/database/seeders/Dictionaries/DictionariesTableSeeder.php @@ -33,9 +33,9 @@ class DictionariesTableSeeder extends Seeder { 'title' => 'Перечни ПП', 'items' => ['pp1521' => 'ПП №1521 от 26.12.2014 г.', 'pp985' => 'ПП № 985 от 04.07.2020 г.', 'pp815' => 'ПП № 815 от 28.05.2021 г.'] ], - 'images-types' => [ + 'image-type' => [ 'title' => 'Тип изображения', - 'items' => ['full-width' => 'во всю ширину', 'tiles' => 'плиткой'] + 'items' => ['full-width' => 'во всю ширину', 'tiles' => 'плиткой', 'carousel' => 'карусель'] ], 'activities' => [ 'title' => 'Направления деятельности', diff --git a/database/seeders/Objects/FieldsTableSeeder.php b/database/seeders/Objects/FieldsTableSeeder.php index a5804a5..006a4e3 100644 --- a/database/seeders/Objects/FieldsTableSeeder.php +++ b/database/seeders/Objects/FieldsTableSeeder.php @@ -64,13 +64,13 @@ class FieldsTableSeeder extends Seeder { 'multiple' => true, 'required' => true ], - 'images-type' => [ + 'image-type' => [ 'title' => 'Тип изображения', 'type' => FieldType::RELATION, 'required' => true, 'params' => [ 'related' => DictionaryItem::class, 'transformer' => DictionaryItemTransformer::class, - 'options' => ['show' => true, 'whereHas' => ['dictionary' => ['name' => 'images-types']]] + 'options' => ['show' => true, 'whereHas' => ['dictionary' => ['name' => 'image-type']]] ] ], diff --git a/database/seeders/Objects/ObjectTypeFieldsTableSeeder.php b/database/seeders/Objects/ObjectTypeFieldsTableSeeder.php index b19785d..afe1c37 100644 --- a/database/seeders/Objects/ObjectTypeFieldsTableSeeder.php +++ b/database/seeders/Objects/ObjectTypeFieldsTableSeeder.php @@ -28,7 +28,7 @@ class ObjectTypeFieldsTableSeeder extends Seeder { 'page-section-images' => [ 'common' => [ - 'fields' => ['images-required', 'images-type'] + 'fields' => ['images-required', 'image-type'] ] ], 'page-section-documents' => [ diff --git a/database/seeders/Pages/PagesTableSeeder.php b/database/seeders/Pages/PagesTableSeeder.php index 58c2c9e..2387254 100644 --- a/database/seeders/Pages/PagesTableSeeder.php +++ b/database/seeders/Pages/PagesTableSeeder.php @@ -14,69 +14,56 @@ class PagesTableSeeder extends Seeder public array $pages = [ 'О центре' => [ 'children' => [ + 'История' => [], 'Руководство' => [], 'Документы' => [ 'children' => [ 'Документы об учреждении' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], + 'Нормативные правовые акты' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], + 'Наблюдательный совет' => [], + 'Государственное задание' => [], 'Закупки' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], 'Бухгалтерская отчетность' => [], - 'Государственное задание' => [], - 'Нормативные правовые акты' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], 'Антимонопольное законодательство' => [], - 'Специальная оценка условий труда' => [] ] ], - 'Структура' => [], - 'Наблюдательный совет' => [ - 'children' => [ - 'Структура' => [], - 'Документы' => [], - 'Решения' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE] - ] - ], - 'Закупки' => [], - 'Противодействие коррупции' => [ - 'children' => [ - 'ФЗ, указы, постановления' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED], - 'Ведомственные нормативные правовые акты' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::SIMPLE], - 'Внутренние нормативные документы' => [], - 'Антикоррупционная экспертиза' => [], - 'Методические материалы' => [], - 'Формы документов для заполнения' => [], - 'Финансовые сведения' => [], - 'Aттестационная комиссия' => [], - 'Обратная связь' => [], - 'Остальные документы' => [] - ] - ] ] ], 'Деятельность' => [ 'children' => [ - 'Нормирование и стандартизация' => [ - 'children' => [ - 'Реестр сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET], - 'Разработка сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DEVELOPMENTS], - 'Прикладные исследования' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RESEARCHES], - 'Реестр нормативно-технической документации' => [], - 'Методические материалы' => [], - ] - ], 'Оценка пригодности' => [ 'children' => [ 'Реестр технических свидетельств' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::TECHNICAL_CERTIFICATES], 'Заявка на оформление' => [], - 'Предварительная заявка' => [], + 'Консультационные услуги' => [], ] ], - 'Технический комитет 465 «Строительство»' => [ + 'ТК 465 “Строительство”' => [ 'children' => [ 'Руководство' => [], - 'Секретариат' => [], - 'Структура' => ['type' => PageType::TK_STRUCTURE], 'Состав' => [], 'Документы' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::CATEGORIZED], - 'АИС ТК 465 «Строительство»' => [], + 'АИС ТК 465 “Строительство”' => [], + //'Структура' => ['type' => PageType::TK_STRUCTURE], + ] + ], + 'Реестр требований ФЗ-63' => [], + 'Нормирование и стандартизация' => [ + 'children' => [ + 'Реестр нормативно-технической документации' => [], + 'Разработка сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::DEVELOPMENTS], + 'Прикладные исследования' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RESEARCHES], + 'Методические материалы' => [], + //'Реестр сводов правил' => ['type' => PageType::REGISTRY, 'registry_type' => RegistryType::RULESET], + ] + ], + 'Международная деятельность' => [ + 'children' => [ + 'ISO' => [], + 'МТК 465 “Строительство”' => [], + 'Межправительственный совет' => [], + 'Базовая организация СНГ' => [], + 'Разработка ТР ЕАЭС' => [], ] ], 'СТУ' => [ @@ -87,41 +74,41 @@ class PagesTableSeeder extends Seeder 'Ответы на часто задаваемые вопросы' => [], ] ], - 'КСИ' => [ - 'children' => [ - - ] - ], + 'КСИ' => [], 'Добровольная сертификация' => [ '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::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], ] ], - 'Международная деятельность' => [ - 'children' => [ - 'ISO' => [], - 'МТК 465 «Строительство»' => [], - 'Межправительственный совет' => [], - 'Базовая организация СНГ' => [], - ] - ], ] ], - 'Коммерческие услуги' => [ + 'Услуги' => [ 'children' => [ - 'Сопровождение экспертизы и утверждения СП и ГОСТ' => [], - 'Сопровождение разработки и утверждения СП и ГОСТ' => [], - 'Консалтинговые услуги по разработке СП и ГОСТ' => [], - 'Экспертиза СТО и ТУ' => [], - 'Редактирование и нормоконтроль' => [], + 'Технические свидетельства' => [ + 'children' => [ + 'Консалтинговые услуги ТС' => [], + ] + ], + 'Консалтинг' => [ + 'children' => [ + 'Экспертиза тех регулирования' => [], + 'Разработка нормативных документов' => [], + 'Нормативный консалтинг' => [], + ] + ], + 'Портфолио проектов' => [ + 'type' => PageType::PUBLICATIONS, + 'sub_type' => PageSubType::PUBLICATION_PORTFOLIO + ], ] ], 'Пресс-центр' => [ @@ -130,18 +117,22 @@ class PagesTableSeeder extends Seeder 'type' => PageType::PUBLICATIONS, 'sub_type' => PageSubType::PUBLICATION_NEWS ], - 'СМИ о нас' => [ - 'type' => PageType::PUBLICATIONS, - 'sub_type' => PageSubType::PUBLICATION_SMI - ], - 'Фотогалерея' => [ - 'type' => PageType::PUBLICATIONS, - 'sub_type' => PageSubType::PUBLICATION_PHOTOS - ], - 'Видеоархив' => [ - 'type' => PageType::PUBLICATIONS, - 'sub_type' => PageSubType::PUBLICATION_VIDEO + 'Медиа' => [ +// 'type' => PageType::PUBLICATIONS, +// 'sub_type' => PageSubType::PUBLICATION_NEWS ], +// 'СМИ о нас' => [ +// 'type' => PageType::PUBLICATIONS, +// 'sub_type' => PageSubType::PUBLICATION_SMI +// ], +// 'Фотогалерея' => [ +// 'type' => PageType::PUBLICATIONS, +// 'sub_type' => PageSubType::PUBLICATION_PHOTOS +// ], +// 'Видеоархив' => [ +// 'type' => PageType::PUBLICATIONS, +// 'sub_type' => PageSubType::PUBLICATION_VIDEO +// ], 'Контакты для СМИ' => [], ] ],