add 'info' field as an array in DirectionStudy model; update DirectionStudyResource to include tabs for main information and admission details; modify Show.vue to display direction study information; enhance PageItemBlock.vue for better breadcrumb display

This commit is contained in:
F4ilji
2025-07-27 21:33:00 +05:00
parent cb95af3c46
commit 8b2f9e99f0
5 changed files with 134 additions and 84 deletions
@@ -17,6 +17,7 @@ class DirectionStudy extends Model
protected $casts = [
'lvl_edu' => LevelEducational::class,
'info' => 'array',
];
public function programs(): HasMany
@@ -2,14 +2,25 @@
namespace App\Filament\Resources;
use App\Containers\Article\Enums\PostStatus;
use App\Containers\Article\Models\Category;
use App\Containers\Education\Models\DirectionStudy;
use App\Containers\Widget\Models\Slider;
use App\Filament\Components\Forms\ItemForm\Pages\ContentBuilderItem;
use App\Filament\Resources\DirectionStudyResource\Pages;
use App\Ship\Enums\Education\LevelEducational;
use Filament\Forms;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieTagsInput;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
@@ -36,50 +47,65 @@ class DirectionStudyResource extends Resource
->description('Заполните основные данные о направлении подготовки')
->collapsible()
->schema([
Grid::make(2)
->schema([
TextInput::make('name')
->label('Название направления')
->required()
->maxLength(255)
->placeholder('Например: Информатика и вычислительная техника')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, ?string $state, Forms\Set $set) {
$set('slug', Str::slug($state));
})
->helperText('Полное название направления подготовки'),
Tabs::make('Tabs')
->tabs([
Tabs\Tab::make('Основная информация')
->icon('heroicon-o-information-circle')
->schema([
Grid::make(2)
->schema([
TextInput::make('name')
->label('Название направления')
->required()
->maxLength(255)
->placeholder('Например: Информатика и вычислительная техника')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, ?string $state, Forms\Set $set) {
$set('slug', Str::slug($state));
})
->helperText('Полное название направления подготовки'),
TextInput::make('uuid')
->label('uuid')
->required()
->maxLength(255)
->unique(ignoreRecord: true)
->helperText('UUID'),
TextInput::make('uuid')
->label('uuid')
->required()
->maxLength(255)
->unique(ignoreRecord: true)
->helperText('UUID'),
TextInput::make('slug')
->label('URL-идентификатор')
->required()
->readOnly()
->maxLength(255)
->unique(ignoreRecord: true)
->helperText('Человеко-понятный URL для направления'),
TextInput::make('slug')
->label('URL-идентификатор')
->required()
->readOnly()
->maxLength(255)
->unique(ignoreRecord: true)
->helperText('Человеко-понятный URL для направления'),
TextInput::make('code')
->label('Код направления')
->required()
->maxLength(50)
->placeholder('Например: 09.03.01')
->helperText('Код направления по ФГОС'),
TextInput::make('code')
->label('Код направления')
->required()
->maxLength(50)
->placeholder('Например: 09.03.01')
->helperText('Код направления по ФГОС'),
Select::make('lvl_edu')
->label('Уровень образования')
->options(LevelEducational::class)
->required()
->native(false)
->placeholder('Выберите уровень')
->helperText('Выберите уровень образовательной программы'),
]),
Select::make('lvl_edu')
->label('Уровень образования')
->options(LevelEducational::class)
->required()
->native(false)
->placeholder('Выберите уровень')
->helperText('Выберите уровень образовательной программы'),
]),
]),
Tabs\Tab::make('Информация для направления')
->icon('heroicon-o-document-text')
->schema([
ContentBuilderItem::getItem('info')
->required()
->helperText('Создайте содержимое новости используя конструктор'),
]),
])
->persistTabInQueryString(),
]),
]);
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('direction_studies', function (Blueprint $table) {
$table->text('info')->nullable()->after('lvl_edu');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('direction_studies', function (Blueprint $table) {
$table->dropColumn('info');
});
}
};
+3 -3
View File
@@ -214,7 +214,7 @@ export default {
</div>
</div>
<div v-if="program.data.program_features" class="hs-accordion bg-white border -mt-px first:rounded-t-lg last:rounded-b-lg" id="hs-bordered-heading-three">
<div v-if="program.data.directionStudy.info" class="hs-accordion bg-white border -mt-px first:rounded-t-lg last:rounded-b-lg" id="hs-bordered-heading-three">
<button class="hs-accordion-toggle hs-accordion-active:text-primary inline-flex items-center gap-x-3 w-full font-semibold text-start text-gray-800 py-4 px-5 hover:text-gray-500 disabled:opacity-50 disabled:pointer-events-none" aria-controls="hs-basic-bordered-collapse-three">
<svg class="hs-accordion-active:hidden block size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14"></path>
@@ -223,11 +223,11 @@ export default {
<svg class="hs-accordion-active:block hidden size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M5 12h14"></path>
</svg>
Особенности программы
Информация для поступающих
</button>
<div id="hs-basic-bordered-collapse-three" class="hs-accordion-content hidden w-full overflow-hidden transition-[height] duration-300" aria-labelledby="hs-bordered-heading-three">
<div class="pb-4 px-5">
<Builder :blocks="program.data.program_features" />
<Builder :blocks="program.data.directionStudy.info" />
</div>
</div>
</div>
@@ -12,48 +12,43 @@
</div>
</div>
<div v-else class="w-full px-2 py-5 sm:px-3 lg:px-4 lg:py-7 mx-auto">
<!-- Grid -->
<a class="group flex flex-col bg-white border shadow-sm rounded-xl hover:shadow-md focus:outline-none focus:shadow-md transition"
:href="(page.is_url) ? page.path : route('page.view', page.path) + '/'">
<div class="p-4 md:p-5">
<div class="flex items-center gap-x-5">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="mt-1 shrink-0 size-7 text-gray-600">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>
<div class="grow">
<ol class="flex items-center whitespace-nowrap">
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary" href="#">
{{ breadcrumbs.mainSection }}
</span>
<svg class="shrink-0 mx-2 size-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6"></path>
</svg>
</li>
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary" href="#">
{{ breadcrumbs.subSection }}
</span>
<svg class="shrink-0 mx-2 size-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6"></path>
</svg>
</li>
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary" href="#">
{{ breadcrumbs.page }}
</span>
</li>
</ol>
<h3 class="mt-1 group-hover:text-primary-hover font-semibold text-gray-700">
{{ page.title }}
</h3>
</div>
</div>
</div>
</a>
<!-- End Grid -->
</div>
<div v-else class="w-full px-2 sm:px-3 lg:px-4 lg:py-4 mx-auto">
<a class="group flex flex-col bg-white border shadow-sm rounded-xl hover:shadow-md focus:outline-none focus:shadow-md transition"
:href="(page.is_url) ? page.path : route('page.view', page.path) + '/'">
<div class="p-4 md:p-5">
<div class="flex items-center gap-x-5">
<div class="grow min-w-0">
<ol class="flex items-center whitespace-nowrap overflow-hidden hidden md:block">
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary truncate" href="#">
{{ breadcrumbs.mainSection }}
</span>
<svg class="shrink-0 mx-2 size-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6"></path>
</svg>
</li>
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary truncate" href="#">
{{ breadcrumbs.subSection }}
</span>
<svg class="shrink-0 mx-2 size-4 text-gray-400" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6"></path>
</svg>
</li>
<li class="inline-flex items-center">
<span class="flex items-center text-sm text-gray-500 hover:text-primary-hover focus:outline-none focus:text-primary truncate" href="#">
{{ breadcrumbs.page }}
</span>
</li>
</ol>
<p class="mt-1 group-hover:text-primary-hover font-semibold text-gray-700 break-words">
{{ page.title }}
</p>
</div>
</div>
</div>
</a>
</div>
</template>