Skip to content

Commit

Permalink
Merge branch 'main' into rectoooor
Browse files Browse the repository at this point in the history
  • Loading branch information
GeniJaho committed Mar 26, 2024
2 parents f02de5d + 46f1e5c commit 2a243b2
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 39 deletions.
7 changes: 0 additions & 7 deletions app/Filament/Resources/ItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public static function form(Form $form): Form
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(191),
TextInput::make('slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Expand All @@ -50,10 +47,6 @@ public static function table(Table $table): Table
->sortable()
->toggleable()
->numeric(),
TextColumn::make('slug')
->sortable()
->searchable()
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('created_at')
->dateTime()
->sortable()
Expand Down
7 changes: 0 additions & 7 deletions app/Filament/Resources/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public static function form(Form $form): Form
->required()
->relationship(name: 'type', titleAttribute: 'name'),
TextInput::make('name')
->required()
->maxLength(191),
TextInput::make('slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Expand All @@ -48,10 +45,6 @@ public static function table(Table $table): Table
TextColumn::make('name')
->sortable()
->searchable(),
TextColumn::make('slug')
->sortable()
->searchable()
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('type.name')
->sortable()
->searchable(),
Expand Down
6 changes: 1 addition & 5 deletions database/factories/ItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\Item;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @extends Factory<Item>
Expand All @@ -18,11 +17,8 @@ class ItemFactory extends Factory
*/
public function definition(): array
{
$name = fake()->unique()->sentence();

return [
'name' => $name,
'slug' => Str::slug($name),
'name' => fake()->unique()->sentence(),
];
}
}
6 changes: 1 addition & 5 deletions database/factories/TagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Models\Tag;
use App\Models\TagType;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @extends Factory<Tag>
Expand All @@ -19,12 +18,9 @@ class TagFactory extends Factory
*/
public function definition(): array
{
$word = $this->faker->unique()->word();

return [
'tag_type_id' => TagType::factory(),
'name' => $word,
'slug' => Str::slug($word),
'name' => fake()->unique()->word(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public function up(): void
$table->id();
$table->foreignId('tag_type_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('slug')->unique();
$table->timestamps();
});
}
Expand Down
11 changes: 1 addition & 10 deletions database/migrations/2023_09_04_215634_create_items_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ public function up(): void
{
Schema::create('items', function (Blueprint $table): void {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('name')->unique();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('items');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('tags', function (Blueprint $table) {
$table->unique('name');
});
}
};
2 changes: 0 additions & 2 deletions database/seeders/ItemSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\Item;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

class ItemSeeder extends Seeder
{
Expand Down Expand Up @@ -339,7 +338,6 @@ private function format(array $items): array
{
return array_map(fn (string $item): array => [
'name' => $item,
'slug' => Str::slug($item, dictionary: ['<' => 'lt', '>' => 'gt']),
'created_at' => now(),
'updated_at' => now(),
], $items);
Expand Down
2 changes: 0 additions & 2 deletions database/seeders/TagSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\TagType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

class TagSeeder extends Seeder
{
Expand All @@ -31,7 +30,6 @@ private function format(array $tags, Model $type): array
{
return array_map(fn (string $tag): array => [
'name' => $tag,
'slug' => Str::slug($tag),
'tag_type_id' => $type->id,
'created_at' => now(),
'updated_at' => now(),
Expand Down

0 comments on commit 2a243b2

Please sign in to comment.