diff --git a/database/factories/PostFactory.php b/database/factories/PostFactory.php index c667900e..e70122b3 100644 --- a/database/factories/PostFactory.php +++ b/database/factories/PostFactory.php @@ -4,7 +4,6 @@ use App\Models\Author; use App\Models\Post; -use Closure; use Illuminate\Database\Eloquent\Factories\Factory; class PostFactory extends Factory @@ -27,6 +26,7 @@ public function configure() return $this->afterCreating(function (Post $post) { $tags = ['php', 'laravel', 'javascript']; + $post->attachTags( $this->faker->randomElements($tags, faker()->numberBetween(1, 3)) ); diff --git a/database/migrations/2024_06_06_121323_create_posts_table.php b/database/migrations/2024_06_06_121323_create_posts_table.php index 610ad5b3..edcd34ca 100644 --- a/database/migrations/2024_06_06_121323_create_posts_table.php +++ b/database/migrations/2024_06_06_121323_create_posts_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { public function up() { Schema::create('posts', function (Blueprint $table) { diff --git a/database/migrations/2024_06_06_122130_create_tag_tables.php b/database/migrations/2024_06_06_122130_create_tag_tables.php index 5925c6cf..6193d6f9 100644 --- a/database/migrations/2024_06_06_122130_create_tag_tables.php +++ b/database/migrations/2024_06_06_122130_create_tag_tables.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { public function up(): void { Schema::create('tags', function (Blueprint $table) { diff --git a/database/migrations/2024_06_06_122320_create_authors_table.php b/database/migrations/2024_06_06_122320_create_authors_table.php index 1f2972c6..7dc12861 100644 --- a/database/migrations/2024_06_06_122320_create_authors_table.php +++ b/database/migrations/2024_06_06_122320_create_authors_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { public function up() { Schema::create('authors', function (Blueprint $table) { diff --git a/database/migrations/2024_06_06_122342_create_author_post_table.php b/database/migrations/2024_06_06_122342_create_author_post_table.php index 3d621d04..f1d60f8c 100644 --- a/database/migrations/2024_06_06_122342_create_author_post_table.php +++ b/database/migrations/2024_06_06_122342_create_author_post_table.php @@ -6,8 +6,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { public function up() { Schema::create('author_post', function (Blueprint $table) {