diff --git a/app/Models/DirectionProfile.php b/app/Models/DirectionProfile.php index e651bf7..4b8dc1b 100644 --- a/app/Models/DirectionProfile.php +++ b/app/Models/DirectionProfile.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; class DirectionProfile extends Model { @@ -16,11 +17,10 @@ class DirectionProfile extends Model 'description', 'slug', 'position', - 'direction_id' ]; - public function direction(): BelongsTo + public function direction(): BelongsToMany { - return $this->belongsTo(Direction::class); + return $this->belongsToMany(Direction::class); } } diff --git a/database/factories/DirectionProfileFactory.php b/database/factories/DirectionProfileFactory.php index 82c42ed..effd458 100644 --- a/database/factories/DirectionProfileFactory.php +++ b/database/factories/DirectionProfileFactory.php @@ -13,7 +13,6 @@ class DirectionProfileFactory extends Factory 'description' => fake()->text(), 'slug' => fake()->slug(), 'position' => 1, - 'direction_id' => 1, ]; } } diff --git a/database/migrations/2024_02_26_064138_create_direction_profiles_table.php b/database/migrations/2024_02_26_064138_create_direction_profiles_table.php index 31e4e3f..d2f24cf 100644 --- a/database/migrations/2024_02_26_064138_create_direction_profiles_table.php +++ b/database/migrations/2024_02_26_064138_create_direction_profiles_table.php @@ -17,7 +17,6 @@ return new class extends Migration $table->text('description')->nullable(); $table->string('slug'); $table->string('position'); - $table->foreignId('direction_id')->constrained('directions'); $table->timestamps(); }); } diff --git a/database/migrations/2024_02_19_110011_create_place_types_table.php b/database/migrations/2024_02_29_110734_create_direction_direction_profile.php similarity index 57% rename from database/migrations/2024_02_19_110011_create_place_types_table.php rename to database/migrations/2024_02_29_110734_create_direction_direction_profile.php index aedfcba..4bece2e 100644 --- a/database/migrations/2024_02_19_110011_create_place_types_table.php +++ b/database/migrations/2024_02_29_110734_create_direction_direction_profile.php @@ -11,12 +11,10 @@ return new class extends Migration */ public function up(): void { - Schema::create('place_types', function (Blueprint $table) { + Schema::create('direction_direction_profile', function (Blueprint $table) { $table->id(); - $table->integer('position'); - $table->string('name'); - $table->text('description')->nullable(); - $table->string('slug'); + $table->foreignId('direction_id')->constrained('directions'); + $table->foreignId('direction_profile_id')->constrained('direction_profiles'); $table->timestamps(); }); } @@ -26,6 +24,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('place_types'); + Schema::dropIfExists('direction_direction_profile'); } }; diff --git a/database/seeders/DirectionProfileSeeder.php b/database/seeders/DirectionProfileSeeder.php index 2f9d648..2849cf4 100644 --- a/database/seeders/DirectionProfileSeeder.php +++ b/database/seeders/DirectionProfileSeeder.php @@ -16,21 +16,18 @@ class DirectionProfileSeeder extends Seeder 'description' => 'Государственно-правовой профиль', 'slug' => 'the-state-legal', 'position' => 1, - 'direction_id' => 1, ], [ 'name' => 'Условно-правовой', 'description' => 'Условно-правовой профиль', 'slug' => 'probationary-profile', 'position' => 2, - 'direction_id' => 1, ], [ 'name' => 'Цифровой Юрист', 'description' => 'Цифровой Юрист профиль', 'slug' => 'digital-lawyer', 'position' => 3, - 'direction_id' => 1, ], ]); } diff --git a/resources/views/admin/catalog/direction/direction_profile/create.blade.php b/resources/views/admin/catalog/direction/direction_profile/create.blade.php index f0f1614..5a95909 100644 --- a/resources/views/admin/catalog/direction/direction_profile/create.blade.php +++ b/resources/views/admin/catalog/direction/direction_profile/create.blade.php @@ -18,18 +18,6 @@ @endif -
- {{ Form::label('direction_id', 'Направление подготовки') }} -
-
- {{ Form::select('direction_id', $directions, null, ['class' => 'form-select']) }} -
-
- @if ($errors->any()) - {{ $errors->first('direction_id') }} - @endif -
-
{{ Form::label('description', 'Описание') }}
diff --git a/resources/views/admin/catalog/direction/direction_profile/edit.blade.php b/resources/views/admin/catalog/direction/direction_profile/edit.blade.php index 882e8ae..caf84b0 100644 --- a/resources/views/admin/catalog/direction/direction_profile/edit.blade.php +++ b/resources/views/admin/catalog/direction/direction_profile/edit.blade.php @@ -18,18 +18,6 @@ @endif -
- {{ Form::label('direction_id', 'Направление подготовки') }} -
-
- {{ Form::select('direction_id', $directions, $directionProfile->direction->id, ['class' => 'form-select']) }} -
-
- @if ($errors->any()) - {{ $errors->first('direction_id') }} - @endif -
-
{{ Form::label('description', 'Описание') }}
diff --git a/resources/views/admin/catalog/direction/direction_profile/index.blade.php b/resources/views/admin/catalog/direction/direction_profile/index.blade.php index 15d296a..114ff33 100644 --- a/resources/views/admin/catalog/direction/direction_profile/index.blade.php +++ b/resources/views/admin/catalog/direction/direction_profile/index.blade.php @@ -10,7 +10,6 @@ Название - Направление подготовки Описание Позиция URL @@ -22,7 +21,6 @@ @foreach($directionProfiles as $directionProfile) {{ $directionProfile->name }} - {{ $directionProfile->direction->name }} {{ Str::words($directionProfile->description, 10, '...') }} {{ $directionProfile->position }} {{ $directionProfile->slug }} diff --git a/resources/views/admin/catalog/direction/direction_profile/show.blade.php b/resources/views/admin/catalog/direction/direction_profile/show.blade.php index 7a09700..296ac3b 100644 --- a/resources/views/admin/catalog/direction/direction_profile/show.blade.php +++ b/resources/views/admin/catalog/direction/direction_profile/show.blade.php @@ -4,8 +4,6 @@

Название

{{ $directionProfile->name }}

-

Направление подготовки

-

{{ $directionProfile->direction->name }}

Описание

{{ $directionProfile->description }}

Позиция