From a30f5990c8b61b07604ef1191480baeab01a7425 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:34:42 +0300 Subject: [PATCH 01/24] added recipe factories --- database/factories/RecipeFactory.php | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 database/factories/RecipeFactory.php diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php new file mode 100644 index 0000000..bc17a8f --- /dev/null +++ b/database/factories/RecipeFactory.php @@ -0,0 +1,85 @@ + + */ +class RecipeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $faker = \Faker\Factory::create(); + $this->faker->addProvider(new Restaurant($faker)); + $this->faker->addProvider(new Youtube($faker)); + + return [ + 'title' => $this->faker->foodName(), + 'image' => $this->generateImageFile('recipes'), + 'state' => $this->faker->randomElement(['active', 'archived']), + 'cooking_time' => $this->faker->numberBetween(0, 59), + 'ingredients' => $this->createQuentityIngredients($this->faker->randomDigitNotNull()), // quentity - от 1 до 10 randomDigitNotNull + 'type' => $this->faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']), + 'description' => $this->faker->text(), + 'steps' => $this->createQuentitySteps($this->faker->randomDigitNotNull()), + 'video_url' => $this->faker->youtubeRandomUri(), + ]; + } + + private function generateImageFile(string $name) + { + Storage::fake($name); + $file = UploadedFile::fake()->image($name . '.png'); + return $file->store($name, 'public'); + } + + private function generateIngredients(): array + { + return [ + 'name' => $this->faker->foodName(), + 'unit' => $this->faker->randomElement(['гр', 'ч. ложек', 'cт. ложек', 'мл', 'шт', 'зубчик', 'по вкусу']), + 'portion' => $this->faker->randomNumber(3, true), + ]; + } + + private function generateSteps(): array + { + return [ + 'image' => $this->generateImageFile('steps'), + 'description' => $this->faker->text(), + ]; + } + + private function createQuentitySteps($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateSteps(); + } + + return $result; + } + + private function createQuentityIngredients($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateIngredients(); + } + + return $result; + } +} From 8636c4d42a98f97e5ebb376c201be0535b0c246d Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:16 +0300 Subject: [PATCH 02/24] added recipe seeder --- database/seeders/RecipeSeeder.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 database/seeders/RecipeSeeder.php diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php new file mode 100644 index 0000000..800b7df --- /dev/null +++ b/database/seeders/RecipeSeeder.php @@ -0,0 +1,17 @@ +count(10)->create(); + } +} From aab4ec3afe9d1d3c6c5eba3ceefc03384fe40984 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:28 +0300 Subject: [PATCH 03/24] added recipe author seeder --- database/seeders/RecipeAuthor.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/seeders/RecipeAuthor.php diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php new file mode 100644 index 0000000..58c6319 --- /dev/null +++ b/database/seeders/RecipeAuthor.php @@ -0,0 +1,25 @@ + 0 && Recipe::count() > 0) { + Recipe::each(function ($recipe) { + User::inRandomOrder() + ->first() + ->author_of_recipe() + ->attach($recipe->id); + }); + } + } +} From 39192ff42d436c95dc6143f0373cf21ab7cebed7 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:25 +0300 Subject: [PATCH 04/24] added Recipe comment --- database/factories/RecipeCommentFactory.php | 26 +++++++++++++++ database/seeders/RecipeCommentSeeder.php | 37 +++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 database/factories/RecipeCommentFactory.php create mode 100644 database/seeders/RecipeCommentSeeder.php diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php new file mode 100644 index 0000000..678f38a --- /dev/null +++ b/database/factories/RecipeCommentFactory.php @@ -0,0 +1,26 @@ + + */ +class RecipeCommentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + + return [ + 'grade' => $this->faker->randomDigit(), + 'body' => $this->faker->text(), + ]; + + } +} diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php new file mode 100644 index 0000000..3b24f5c --- /dev/null +++ b/database/seeders/RecipeCommentSeeder.php @@ -0,0 +1,37 @@ + 0 && Recipe::count() > 0) { + $comments = RecipeComment::factory()->count(5)->make(); + + $comments->each(function ($comment) { + $comment->author()->associate( + User::inRandomOrder() + ->first() + ->id + ); + + $comment->recipe()->associate( + Recipe::inRandomOrder() + ->first() + ->id + ); + + $comment->saveOrFail(); + }); + } + } +} From 3726ac3a8305dcb1102e3daccf1ebc7dea3af0c7 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:44 +0300 Subject: [PATCH 05/24] added recipe seeders to database seeder --- database/seeders/DatabaseSeeder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4a70195..0fee10b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -17,7 +17,9 @@ class DatabaseSeeder extends Seeder $this->call(UserSeeder::class); $this->call(PlanAuthor::class); $this->call(PlanCommentSeeder::class); - // $this->call(RecipeSeeder::class); + $this->call(RecipeSeeder::class); + $this->call(RecipeAuthor::class); + $this->call(RecipeCommentSeeder::class); // \App\Models\User::factory(10)->create(); } } From 2674f5c1be6a68307802b381d1658511cff05d37 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 15:01:03 +0300 Subject: [PATCH 06/24] recipe seeder and factories fix code style --- database/factories/RecipeCommentFactory.php | 4 ++-- database/factories/RecipeFactory.php | 6 ++++-- database/seeders/DatabaseSeeder.php | 10 +++------- database/seeders/RecipeAuthor.php | 4 +++- database/seeders/RecipeCommentSeeder.php | 4 +++- database/seeders/RecipeSeeder.php | 4 +++- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php index 678f38a..bea271f 100644 --- a/database/factories/RecipeCommentFactory.php +++ b/database/factories/RecipeCommentFactory.php @@ -1,5 +1,7 @@ $this->faker->randomDigit(), 'body' => $this->faker->text(), ]; - } } diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php index bc17a8f..edf251e 100644 --- a/database/factories/RecipeFactory.php +++ b/database/factories/RecipeFactory.php @@ -1,5 +1,7 @@ generateSteps(); } @@ -76,7 +78,7 @@ class RecipeFactory extends Factory { $result = []; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $result[] = $this->generateIngredients(); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0fee10b..b4935ee 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -1,17 +1,14 @@ call(PlanSeeder::class); $this->call(UserSeeder::class); @@ -20,6 +17,5 @@ class DatabaseSeeder extends Seeder $this->call(RecipeSeeder::class); $this->call(RecipeAuthor::class); $this->call(RecipeCommentSeeder::class); - // \App\Models\User::factory(10)->create(); } } diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php index 58c6319..5381a41 100644 --- a/database/seeders/RecipeAuthor.php +++ b/database/seeders/RecipeAuthor.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { - Recipe::each(function ($recipe) { + Recipe::each(static function ($recipe): void { User::inRandomOrder() ->first() ->author_of_recipe() diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php index 3b24f5c..eb60093 100644 --- a/database/seeders/RecipeCommentSeeder.php +++ b/database/seeders/RecipeCommentSeeder.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { $comments = RecipeComment::factory()->count(5)->make(); - $comments->each(function ($comment) { + $comments->each(static function ($comment): void { $comment->author()->associate( User::inRandomOrder() ->first() diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 800b7df..9c4588e 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -1,9 +1,11 @@ Date: Thu, 21 Dec 2023 17:13:33 +0300 Subject: [PATCH 07/24] added create recipe test --- tests/Feature/Recipe/CreateTest.php | 200 ++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 tests/Feature/Recipe/CreateTest.php diff --git a/tests/Feature/Recipe/CreateTest.php b/tests/Feature/Recipe/CreateTest.php new file mode 100644 index 0000000..f2893fe --- /dev/null +++ b/tests/Feature/Recipe/CreateTest.php @@ -0,0 +1,200 @@ +image = UploadedFile::fake()->image('recipe.jpg'); + + $this->user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::factory()->make(); + + $this->refreshApplicationWithLocale('en'); + } + + public function testShowFormCreateRecipe(): void + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.create')); + + $response->assertSuccessful(); + } + + public function testPublishNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('publish') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + } + + public function testToDraftNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('draft') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + + self::assertEquals(Recipe::find($count + 1)->state, 'archived'); + } + + public function testToPreviewNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('preview') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + + self::assertEquals(Recipe::find($count + 1)->state, 'archived'); + } + + public function testSetEmptyData(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', null) + ->set('state', null) + ->set('cooking_time', null) + ->set('type', null) + ->set('description', null) + ->call('publish') + ->assertHasErrors(['image', 'state', 'type', 'description']); + + // doesnt to add to database + self::assertEquals($count, Recipe::count()); + } + + public function testIncorrectVideoUrl(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', 'video_url') + ->call('publish') + ->assertSuccessful() + ->assertHasErrors(['video_url']); + + // doesnt to add to database + self::assertEquals($count, Recipe::count()); + } +} From 2bd0a574c63fe2962532edc342a0b832c3104702 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 17:16:05 +0300 Subject: [PATCH 08/24] added youtube url faker --- composer.json | 1 + composer.lock | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20adde8..7f1ada7 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.0.2", + "aalaap/faker-youtube": "^2.0", "asantibanez/livewire-charts": "^3.0", "barryvdh/laravel-debugbar": "^3.6", "cyrildewit/eloquent-viewable": "^7.0", diff --git a/composer.lock b/composer.lock index de1d128..5015c72 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cec18c9498d636695e0fcc9ba3d8ef15", + "content-hash": "f1504229d84c399a1c8aea12005e3530", "packages": [ + { + "name": "aalaap/faker-youtube", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/aalaap/faker-youtube.git", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aalaap/faker-youtube/zipball/eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "shasum": "" + }, + "require": { + "fakerphp/faker": "^1.10", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\Provider\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "WTFPL" + ], + "authors": [ + { + "name": "Aalaap Ghag", + "email": "aalaap@gmail.com" + } + ], + "description": "Faker provider for generating fake YouTube video URLs", + "keywords": [ + "faker", + "provider", + "youtube" + ], + "support": { + "issues": "https://github.com/aalaap/faker-youtube/issues", + "source": "https://github.com/aalaap/faker-youtube/tree/2.0.3" + }, + "time": "2020-11-07T06:43:34+00:00" + }, { "name": "asantibanez/livewire-charts", "version": "v3.0.1", From cd43097c825ac0c59d1704eb231e07dcbd411ad6 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 17:19:51 +0300 Subject: [PATCH 09/24] fix protected to publis setUp --- tests/Feature/Recipe/CreateTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Recipe/CreateTest.php b/tests/Feature/Recipe/CreateTest.php index f2893fe..93a0310 100644 --- a/tests/Feature/Recipe/CreateTest.php +++ b/tests/Feature/Recipe/CreateTest.php @@ -28,7 +28,7 @@ final class CreateTest extends TestCase private $steps; - protected function setUp(): void + public function setUp(): void { parent::setUp(); From 7fafd157244c315f7f70bd602ec6a0e85bc83ff3 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 19:22:59 +0300 Subject: [PATCH 10/24] fix merge composer.lock --- .gitea/workflows/test.yaml | 2 + composer.json | 2 + composer.lock | 92 +++++++++++++++++++++++++++++++++++++- rector.php | 29 ++++++++++++ 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 rector.php diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index a7fbed2..80105f8 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -62,6 +62,8 @@ jobs: - name: Run test run: vendor/bin/phpunit + - name: Code Rewiew + run: vendor/bin/rector process --dry-run #- name: Run Pint # run: vendor/bin/pint diff --git a/composer.json b/composer.json index 7f1ada7..3d5d5fb 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.13", + "driftingly/rector-laravel": "^0.26.2", "fakerphp/faker": "^1.21", "larastan/larastan": "^2.7", "laravel/pint": "^1.13", @@ -40,6 +41,7 @@ "nunomaduro/phpinsights": "^2.11", "phpunit/phpunit": "^10.0", "psalm/phar": "^5.13", + "rector/rector": "^0.18.13", "spatie/laravel-ignition": "^2.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 5015c72..dc67362 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f1504229d84c399a1c8aea12005e3530", + "content-hash": "71767f4485e6335b0a9d934fafcfad8e", "packages": [ { "name": "aalaap/faker-youtube", @@ -10201,6 +10201,40 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "0.26.2", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671", + "reference": "cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/0.26.2" + }, + "time": "2023-10-11T21:42:53+00:00" + }, { "name": "filp/whoops", "version": "2.15.4", @@ -12074,6 +12108,62 @@ }, "time": "2023-12-16T09:41:14+00:00" }, + { + "name": "rector/rector", + "version": "0.18.13", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f8011a76d36aa4f839f60f3b4f97707d97176618", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.10.35" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.18.13" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2023-12-20T16:08:01+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.0", diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..fdad3c1 --- /dev/null +++ b/rector.php @@ -0,0 +1,29 @@ +paths([ + __DIR__ . '/app', + __DIR__ . '/bootstrap', + __DIR__ . '/config', + __DIR__ . '/lang', + __DIR__ . '/public', + __DIR__ . '/resources', + __DIR__ . '/routes', + __DIR__ . '/tests', + ]); + +// $rectorConfig->import(SetList::CODING_STYLE); +// $rectorConfig->import(SetList::CODE_QUALITY); + $rectorConfig->import(SetList::DEAD_CODE); +// $rectorConfig->import(NetteSetList::NETTE_UTILS_CODE_QUALITY); +// $rectorConfig->import(LevelSetList::UP_TO_PHP_82); + $rectorConfig->import(LaravelSetList::LARAVEL_100); +}; + From ed35ffd1812de641a323097f73503cad83267a15 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 21:44:37 +0300 Subject: [PATCH 11/24] added recipe show test --- tests/Feature/Recipe/ShowTest.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/Feature/Recipe/ShowTest.php diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php new file mode 100644 index 0000000..a640b21 --- /dev/null +++ b/tests/Feature/Recipe/ShowTest.php @@ -0,0 +1,35 @@ +user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::inRandomOrder()->first(); + $this->refreshApplicationWithLocale('en'); + } + + public function test_show_form_success() + { + $response = $this->actingAs($this->user) + ->get(route('recipe.show', ['recipe' => $this->recipe->id])); + + $response + ->assertOk(); + } +} From c28870877a1b30b2c89d0a943d6d8fe688094265 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 21:48:37 +0300 Subject: [PATCH 12/24] fix namespace show recipe test --- tests/Feature/Recipe/ShowTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php index a640b21..7e44036 100644 --- a/tests/Feature/Recipe/ShowTest.php +++ b/tests/Feature/Recipe/ShowTest.php @@ -1,6 +1,6 @@ Date: Fri, 22 Dec 2023 10:48:57 +0300 Subject: [PATCH 13/24] added index test recipe --- tests/Feature/Recipe/IndexTest.php | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/Feature/Recipe/IndexTest.php diff --git a/tests/Feature/Recipe/IndexTest.php b/tests/Feature/Recipe/IndexTest.php new file mode 100644 index 0000000..d4ea94a --- /dev/null +++ b/tests/Feature/Recipe/IndexTest.php @@ -0,0 +1,36 @@ +user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::inRandomOrder()->first(); + $this->refreshApplicationWithLocale('en'); + } + + public function test_show_form_success() + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.index')); + + $response + ->assertOk(); + } +} From 0349e05e3991e141035200d6f4e38665104f0651 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Fri, 22 Dec 2023 10:49:17 +0300 Subject: [PATCH 14/24] added edit form test recipe --- tests/Feature/Recipe/EditFormTest.php | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Feature/Recipe/EditFormTest.php diff --git a/tests/Feature/Recipe/EditFormTest.php b/tests/Feature/Recipe/EditFormTest.php new file mode 100644 index 0000000..3975487 --- /dev/null +++ b/tests/Feature/Recipe/EditFormTest.php @@ -0,0 +1,43 @@ +user = User::factory()->create(['is_consultant' => true]); + + $this->recipe = Recipe::inRandomOrder()->first(); + + $this->refreshApplicationWithLocale('en'); + } + + public function testShowFormEditRecipe(): void + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.edit', ['recipe' => $this->recipe->id])); + + $response->assertSuccessful(); + } + +} From 6bf87ef34f6a4c716c6babb8e8abe13c6533f4a2 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 24 Dec 2023 20:33:53 +0300 Subject: [PATCH 15/24] added create recipe page --- app/Livewire/Recipe/Create.php | 62 +-- .../views/livewire/recipe/create.blade.php | 393 +++++++++++------- 2 files changed, 268 insertions(+), 187 deletions(-) diff --git a/app/Livewire/Recipe/Create.php b/app/Livewire/Recipe/Create.php index 65cf6a3..1713ae1 100644 --- a/app/Livewire/Recipe/Create.php +++ b/app/Livewire/Recipe/Create.php @@ -17,6 +17,10 @@ class Create extends Component public $state = 'active'; + public $state_ingredient = 'active'; + + public $state_article = 'active'; + public $tags = []; public $title; @@ -39,20 +43,21 @@ class Create extends Component public $ingredients_unit = 'gr'; + public $state_row = ['ingredient' => 'true', 'article' => 'false']; + protected $listeners = ['stepRemoved' => '$refresh']; - public function render() + + + public function toggleStateRow(string $currentRow): void { - return view('livewire.recipe.create'); + collect($this->state_row)->keys()->map(fn($key) => $key === $currentRow + ? $this->state_row[$currentRow] = 'true' + : $this->state_row[$key] = 'false'); } public function addIngredient(): void { - // dd( - // $this->ingredients_name, - // $this->ingredients_portion, - // $this->ingredients_unit - // ); $this->ingredients[] = [ 'name' => $this->ingredients_name, 'portion' => $this->ingredients_portion, @@ -99,7 +104,7 @@ class Create extends Component public function parentComponentTagRemoved($tag) { $this->tags = collect($this->tags) - ->filter(fn ($curTag) => $curTag['name'] !== $tag) + ->filter(fn($curTag) => $curTag['name'] !== $tag) ->all(); } @@ -117,9 +122,20 @@ class Create extends Component $this->publish(); } + protected function rules() + { + return [ + 'image' => 'required|image|max:2048', + 'state' => 'required|in:active,archived', + 'description' => 'required|min:3', + 'type' => 'required|min:3', + 'video_url' => 'nullable|url|max:2048', + 'cooking_time' => 'nullable|numeric', + ]; + } + public function publish() { - // dd($this->description); $this->validate(); $recipe = new Recipe(); @@ -134,7 +150,7 @@ class Create extends Component $recipe->ingredients = $this->ingredients; $recipe->save(); - $tagsIds = collect($this->tags)->map(fn ($curTag) => $curTag['id']); + $tagsIds = collect($this->tags)->map(fn($curTag) => $curTag['id']); $recipe->tags()->attach($tagsIds); $user = Auth::user(); @@ -143,19 +159,6 @@ class Create extends Component return redirect()->route('recipe.show', $recipe->id); } - protected function rules() - { - return [ - 'image' => 'required|image|max:2048', - 'state' => 'required|in:active,archived', - 'description' => 'required|min:3', - 'type' => 'required|min:3', - 'video_url' => 'nullable|url|max:2048', - 'cooking_time' => 'nullable|numeric', - - ]; - } - private function transformSteps($steps) { return collect($steps)->map( @@ -163,7 +166,7 @@ class Create extends Component if (gettype($step['image']) === 'string') { $data['image'] = $step['image']; } else { - $data['image'] = ! is_null($step['image']) ? $step['image']->store('steps', 'public') : ''; + $data['image'] = !is_null($step['image']) ? $step['image']->store('steps', 'public') : ''; } $data['description'] = $step['description']; @@ -173,8 +176,11 @@ class Create extends Component )->toArray(); } - // public function updated($property) - // { - // dd($property, $this->$property); - // } + + public function render() + { + return view('livewire.recipe.create'); + } + + } diff --git a/resources/views/livewire/recipe/create.blade.php b/resources/views/livewire/recipe/create.blade.php index 397206f..11732a8 100644 --- a/resources/views/livewire/recipe/create.blade.php +++ b/resources/views/livewire/recipe/create.blade.php @@ -1,11 +1,11 @@
-
+
- Мой блог + Мой блог

{{ __('recipe.adding') }}

-
+
{{ __('recipe.title') }}
@@ -24,53 +24,82 @@
-
-
-
{{ __('recipe.picture') }}
-
@php $stepsCount = count($steps); @endphp - @for($i = 0; $i < $stepsCount; $i++) -
-
- {{ __('recipe.step') }} {{ $i + 1 }} - @if($i == 0) - {{ __('recipe.total_steps') }}: {{ $stepsCount }} - @endif -
-
- - -
- - + @for ($i = 0; $i < $stepsCount; $i++) +
+
+ {{ __('recipe.step') }} {{ $i + 1 }} + @if ($i == 0) + {{ __('recipe.total_steps') }}: {{ $stepsCount }} + @endif +
+
+ + +
+ + +
+
-
-
@endfor
-
{{ __('recipe.tags') }}
- - +
{{ __('recipe.tags') }}
+ +
-
{{ __('recipe.video_link') }}
- +
{{ __('recipe.video_link') }}
+
-
+
{{--
@@ -259,7 +332,7 @@
@php $lastIngedient = count($ingredients) - 1; @endphp - @foreach($ingredients as $k => $ingredient) + @foreach ($ingredients as $k => $ingredient)
@@ -303,9 +376,12 @@
--}}
- - - + + +
@@ -315,4 +391,3 @@ @endforeach
- From 587bcff62615f7a34e579bd1dfb2b18a8286f87d Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 24 Dec 2023 22:39:34 +0300 Subject: [PATCH 16/24] added show recipe page --- app/Livewire/Recipe/Comment/Create.php | 15 + app/Livewire/Recipe/Comment/Show.php | 9 + app/Livewire/Recipe/Create.php | 1 + app/Models/Recipe.php | 11 + resources/css/app.css | 9 + .../livewire/recipe/comment/create.blade.php | 64 ++- .../livewire/recipe/comment/show.blade.php | 112 +++-- .../livewire/recipe/comment/upvote.blade.php | 2 +- .../views/livewire/recipe/like.blade.php | 4 +- resources/views/recipe/show.blade.php | 428 ++++++++---------- 10 files changed, 341 insertions(+), 314 deletions(-) diff --git a/app/Livewire/Recipe/Comment/Create.php b/app/Livewire/Recipe/Comment/Create.php index 6541c37..e0a0aff 100644 --- a/app/Livewire/Recipe/Comment/Create.php +++ b/app/Livewire/Recipe/Comment/Create.php @@ -17,13 +17,25 @@ class Create extends Component public $grade = 0; + public $isChecked = false; + public function render() { return view('livewire.recipe.comment.create'); } + public function toggle() + { + $this->isChecked = !$this->isChecked; + } + public function save() { + $this->validate([ + 'body' => 'required|min:3', + 'grade' => 'required', + ]); + $comment = new RecipeComment(); $comment->grade = $this->grade; $comment->body = $this->body; @@ -32,6 +44,9 @@ class Create extends Component $comment->save(); $this->reset(['body', 'grade']); + + $this->toggle(); + $this->dispatch('commentAdded')->to('recipe.comment.show'); } } diff --git a/app/Livewire/Recipe/Comment/Show.php b/app/Livewire/Recipe/Comment/Show.php index e38077f..ca2278f 100644 --- a/app/Livewire/Recipe/Comment/Show.php +++ b/app/Livewire/Recipe/Comment/Show.php @@ -9,10 +9,19 @@ class Show extends Component { public Recipe $recipe; + public array $tabpanelState = ['positive' => 'positive', 'negative' => false]; + protected $listeners = ['commentAdded' => '$refresh']; public function render() { return view('livewire.recipe.comment.show'); } + + public function toggleTabpanelState($tabpanelName) + { + collect($this->tabpanelState)->keys()->map(fn($key) => $key === $tabpanelName + ? $this->tabpanelState[$tabpanelName] = $tabpanelName + : $this->tabpanelState[$key] = false, array_keys($this->tabpanelState)); + } } diff --git a/app/Livewire/Recipe/Create.php b/app/Livewire/Recipe/Create.php index 1713ae1..a1d1c51 100644 --- a/app/Livewire/Recipe/Create.php +++ b/app/Livewire/Recipe/Create.php @@ -136,6 +136,7 @@ class Create extends Component public function publish() { + $this->validate(); $recipe = new Recipe(); diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index beffe35..83959d6 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -7,6 +7,7 @@ use CyrildeWit\EloquentViewable\InteractsWithViews; use Illuminate\Database\Eloquent\Casts\AsCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasMany; class Recipe extends Model implements Viewable @@ -56,6 +57,16 @@ class Recipe extends Model implements Viewable return $this->hasMany(RecipeLike::class); } + public function scopeByNegative(Builder $query) + { + return static::comments()->where('grade', '<=', '3'); + } + + public function scopeByPositive(Builder $query) + { + return static::comments()->where('grade', '>', '3'); + } + public function isLiked(): bool { $curUser = auth()->user(); diff --git a/resources/css/app.css b/resources/css/app.css index a827885..fe60da7 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -21,3 +21,12 @@ .active-icon-heart{ color: #2f80ed; } + + /* Recipe-show like */ +.text-blue-400 { color: #2f80ed; } + +.text-blue-500 { color: #2f80ed;} + +.text-gray-400 { color: #cbd5e0; } + +.text-gray-500 { color: #a0aec0; } diff --git a/resources/views/livewire/recipe/comment/create.blade.php b/resources/views/livewire/recipe/comment/create.blade.php index 8873d7e..727b68f 100644 --- a/resources/views/livewire/recipe/comment/create.blade.php +++ b/resources/views/livewire/recipe/comment/create.blade.php @@ -1,24 +1,46 @@ -
-
- -
- - $grade >= 1]) width="24" height="24"> - - - $grade >= 2]) width="24" height="24"> - - - $grade >= 3]) width="24" height="24"> - - - $grade >= 4]) width="24" height="24"> - - - $grade >= 5]) width="24" height="24"> - +
+
+ +
+
+ $isChecked]) wire:model="isChecked" wire:click="$set('grade', 5)" type="radio" + name="rate" id="rate-5" value="5" hidden> + + $isChecked]) wire:model="isChecked" wire:click="$set('grade',4)" type="radio" + name="rate" id="rate-4" value="4" hidden> + + $isChecked]) wire:model="isChecked" wire:click="$set('grade',3)" type="radio" + name="rate" id="rate-3" value="3" hidden> + + $isChecked]) wire:model="isChecked" wire:click="$set('grade',2)" type="radio" + name="rate" id="rate-2" value="2" hidden> + + $isChecked]) wire:model="isChecked" wire:click="$set('grade',1)" type="radio" + name="rate" id="rate-1" value="1" hidden> + + +
+ -
-
+ + + + + @error('grade') +
+ {{ $message }} +
+ @enderror + + + + @error('body') +
+ {{ $message }} +
+ @enderror + +
diff --git a/resources/views/livewire/recipe/comment/show.blade.php b/resources/views/livewire/recipe/comment/show.blade.php index 361bc41..3308310 100644 --- a/resources/views/livewire/recipe/comment/show.blade.php +++ b/resources/views/livewire/recipe/comment/show.blade.php @@ -1,60 +1,84 @@ -
-
комментарии
+
@php - $positivComments = $recipe->comments()->where('grade', '>', '3'); - $negativeComments = $recipe->comments()->where('grade', '<=', '3'); - $positiveCommmentsCount = $positivComments->count(); - $negativeCommentsCount = $negativeComments->count(); - @endphp - -
-
- @foreach($positivComments->get() as $comment) -
-
- -
- {{ $comment->author->name }} - {{ $comment->body }} + $positivComments = $recipe->byPositive(); + $negativeComments = $recipe->byNegative(); + + $positiveCommmentsCount = $positivComments->count(); + + $negativeCommentsCount = $negativeComments->count(); + + @endphp + +
+
+ + +
+ +
$tabpanelState['negative'] + ]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1"> + @foreach ($positivComments->get() as $comment) +
+
+
+ user
-
-
-
- - {{ $comment->grade }} +
+
+ {{ $comment->author->name }} +
+
+ {{ $comment->body }} +
+
+
+
+ {{ $comment->grade }} +
+
- @livewire('recipe.comment.upvote', ['comment' => $comment])
@endforeach
-
- @foreach($negativeComments->get() as $comment) -
-
- -
- {{ $comment->author->name }} - {{ $comment->body }} + + +
$tabpanelState['positive'] + ]) role="tabpanel" id="tabpanel-2" tabindex="0" aria-labelledby="tab-1"> + @foreach ($negativeComments->get() as $comment) +
+
+
+ user
-
-
-
- - {{ $comment->grade }} +
+
+ {{ $comment->author->name }} +
+
+ {{ $comment->body }} +
+
+
+
+ {{ $comment->grade }} +
+ +
- @livewire('recipe.comment.upvote', ['comment' => $comment])
@endforeach
+
+
diff --git a/resources/views/livewire/recipe/comment/upvote.blade.php b/resources/views/livewire/recipe/comment/upvote.blade.php index 9286173..6dcc9d6 100644 --- a/resources/views/livewire/recipe/comment/upvote.blade.php +++ b/resources/views/livewire/recipe/comment/upvote.blade.php @@ -1,4 +1,4 @@ -
id }}> +
id }}> diff --git a/resources/views/livewire/recipe/like.blade.php b/resources/views/livewire/recipe/like.blade.php index d807ae0..f555a49 100644 --- a/resources/views/livewire/recipe/like.blade.php +++ b/resources/views/livewire/recipe/like.blade.php @@ -1,4 +1,4 @@ - diff --git a/resources/views/recipe/show.blade.php b/resources/views/recipe/show.blade.php index 2c25ff1..db42b65 100644 --- a/resources/views/recipe/show.blade.php +++ b/resources/views/recipe/show.blade.php @@ -1,147 +1,172 @@ @extends('layouts/eatvio') - @section('page_title', 'Recipe ' . $recipe->title) - @php - $recipeViewsCount = views($recipe)->unique()->count(); - @endphp - @section('main_section') -
-
-
- - Рецепты - -
-
- {{ $recipeViewsCount }} -
-
- @livewire('recipe.like-count', ['recipe' => $recipe]) -
-
- {{ $recipe->comments_count }} -
-
-
-
- {{ $author['name'] }} -
-
- @empty($author->profile_photo_path) - thumb - @else - thumb - @endempty -
-
-
-
-
-
-
-
-
-
- recipe -
-
-
-

- {{ $recipe->title }} -

- -
-
-
{{ __('recipe.t' . $recipe->cooking_time . "m") }}
-
{{ $recipe->steps->count() }} этапов
-
-

{!! $recipe->description !!}

- @if (strlen(trim($recipe->video_url)) > 4) - Посмотреть рецепт на YouTube - @endif -
-
-
-
-
- ПРОДУКТЫ: -
-
    - @foreach($recipe->ingredients as $ingredient) - @php - $localizedUnit = (isset($ingredient['unit']) && mb_strlen($ingredient['unit']) > 1) - ? $ingredient['unit'] - : 'gr'; - @endphp - @if(mb_strlen($ingredient['name']) > 1) -
  • {{ $ingredient['name'] }} - {{ $ingredient['portion'] }} {{ __('recipe.' . $localizedUnit ) }}
  • - @endif - @endforeach -
-
-
-
- ЦЕННОСТЬ: -
-
    -
  • WIP
  • - {{-- +@section('page_title', 'Recipe ' . $recipe->title) +@php + $recipeViewsCount = views($recipe) + ->unique() + ->count(); +@endphp +@section('main_section') +
    +
    +
    + + Рецепты + +
    +
    + {{ $recipeViewsCount }} +
    +
    + @livewire('recipe.like-count', ['recipe' => $recipe]) +
    +
    + {{ $recipe->comments_count }} +
    +
    +
    +
    + {{ $author['name'] }} +
    +
    + @empty($author->profile_photo_path) + thumb + @else + thumb + @endempty +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + recipe +
    +
    +
    +

    + {{ $recipe->title }} +

    + +
    + + +
      +
    • + Редактировать +
    • +
    • + +
    • +
    • + +
    • +
    • + +
    • + {{--
    • --}} + {{--
      ID: 2jkfk45JG
      --}} + {{--
    • --}} +
    + +
    + +
    +
    +
    {{ __('recipe.t' . $recipe->cooking_time . 'm') }}
    +
    {{ $recipe->steps->count() }} этапов
    +
    +

    {!! $recipe->description !!}

    + @if (strlen(trim($recipe->video_url)) > 4) + Посмотреть рецепт на YouTube + @endif +
    +
    +
    +
    +
    + ПРОДУКТЫ: +
    +
      + @foreach ($recipe->ingredients as $ingredient) + @php + $localizedUnit = isset($ingredient['unit']) && mb_strlen($ingredient['unit']) > 1 ? $ingredient['unit'] : 'gr'; + @endphp + @if (mb_strlen($ingredient['name']) > 1) +
    • {{ $ingredient['name'] }} - {{ $ingredient['portion'] }} + {{ __('recipe.' . $localizedUnit) }}
    • + @endif + @endforeach +
    +
    +
    +
    + ЦЕННОСТЬ: +
    +
      +
    • WIP
    • + {{--
    • Калории: 139.9 ккал
    • Белки: 20.4 гр
    • Жиры: 5.7 гр
    • Углеводы: 1.8 гр
    • --}} -
    -
    -
    -
    - ЦЕННОСТЬ: -
    -
    - @foreach($recipe->tags->unique() as $curTag) - {{ $curTag->name }} - @endforeach -
    -
    -
    - -
    -
    -
    -
    -
    -

    - ПОШАГОВЫЙ ФОТО РЕЦЕПТ - {{ $recipe->title }} -

    -
      - @foreach($recipe->steps as $step) +
+
+
+
+ ЦЕННОСТЬ: +
+
+ @foreach ($recipe->tags->unique() as $curTag) + {{ $curTag->name }} + @endforeach +
+
+
+ +
+
+
+
+
+

+ ПОШАГОВЫЙ ФОТО РЕЦЕПТ - {{ $recipe->title }} +

+
    + @foreach ($recipe->steps as $step) +
  1. +
    + @if (isset($step['image']) && is_string($step['image']) && strlen($step['image']) > 4) + step + @endif +
    +
    + + {!! $step['description'] !!} + +
    +
  2. + @endforeach -
  3. -
    - @if(isset($step['image']) && is_string($step['image']) && strlen($step["image"]) > 4) - step - @endif -
    -
    - - {!! $step['description'] !!} - -
    -
  4. - @endforeach - - {{--
  5. + {{--
  6. step
    @@ -162,115 +187,26 @@

--}} - -
- -
-
-

- Отзывы -

-
-
- - -
-
-
-
-
- user -
-
-
- Артём -
-
- После данного плана питания стал чувствовать себя куда лучше! Обязательно продолжу работать с Дмитрием! -
-
-
-
- Лёгкий -
-
- 5.0 -
-
-
-
-
- user -
-
-
- Артём -
-
- После данного плана питания стал чувствовать себя куда лучше! Обязательно продолжу работать с Дмитрием! -
-
-
-
- Лёгкий -
-
- 5.0 -
-
-
-
-
-
-
-
-
- user -
-
-
- Артём -
-
- Курить план – это плохо! Гласит лозунг и кричит Минздрав. Ну, конечно …Ничем не хуже водки, а водку везде продают и ничего.. ... Говорят, некоторые годами курят план и живут нормальной жизнью…Ну, если они считают это нормальной жизнью, то пусть и дальше существуют…Я не хочу…Я теперь спрашиваю себя – а зачем мне жить, что б просто курить траву?..Теперь мне плохо и траву курить, Проклятый мир! Даже год не покурил… Мне нужно что-то получше.. почище….ярче!!! -
-
-
-
- Лёгкий -
-
- 5.0 -
-
-
-
-
-
-
- -
-
- - - - - - - - - - -
- -
-
-
-
+ +
+ + +
+
+

+ ОТЗЫВЫ +

+ + @livewire('recipe.comment.show', ['recipe' => $recipe]) + @livewire('recipe.comment.create', ['recipe' => $recipe, 'user' => Auth::user()]) +
- @endsection - @push('jq_scripts') - - - @endpush +
+ + +@endsection +{{-- @push('jq_scripts') --}} +{{-- --}} +{{-- --}} +{{-- @endpush --}} From 7cefb75bfa49b420970365bfa77eb6a1af683535 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 24 Dec 2023 23:27:17 +0300 Subject: [PATCH 17/24] deleted EditFormTest and added EditTest --- tests/Feature/Recipe/EditFormTest.php | 42 ------ tests/Feature/Recipe/EditTest.php | 192 ++++++++++++++++++++++++++ 2 files changed, 192 insertions(+), 42 deletions(-) delete mode 100644 tests/Feature/Recipe/EditFormTest.php create mode 100644 tests/Feature/Recipe/EditTest.php diff --git a/tests/Feature/Recipe/EditFormTest.php b/tests/Feature/Recipe/EditFormTest.php deleted file mode 100644 index 8b24072..0000000 --- a/tests/Feature/Recipe/EditFormTest.php +++ /dev/null @@ -1,42 +0,0 @@ -refreshApplicationWithLocale('en'); - - $this->user = User::factory()->create(['is_consultant' => true]); - - $this->recipe = Recipe::inRandomOrder()->first(); - } - - public function test_edit_page_recipe_success(): void - { - $response = $this - ->actingAs($this->user) - ->get(route('recipe.edit', $this->recipe, false)); - - $response->assertSuccessful(); - } - -} - diff --git a/tests/Feature/Recipe/EditTest.php b/tests/Feature/Recipe/EditTest.php new file mode 100644 index 0000000..ba5bb22 --- /dev/null +++ b/tests/Feature/Recipe/EditTest.php @@ -0,0 +1,192 @@ +refreshApplicationWithLocale('en'); + + $this->user = User::factory()->create(['is_consultant' => true]); + + $this->recipe = Recipe::inRandomOrder()->first(); + } + + public function test_edit_page_recipe_success(): void + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.edit', $this->recipe, false)); + + $response->assertSuccessful(); + } + + public function testUpdateRecipePublishSuccess(): void + { + $this->actingAs($this->user); + + $recipe = $this->recipe = Recipe::factory()->make(); + + $recipeUpdate = Livewire::test(Edit::class, [ + 'recipe' => $this->recipe, + ]) + ->set('title', $recipe->title) + ->assertSet('title', $recipe->title) + ->set('image', $recipe->image) + ->set('state', $recipe->state) + ->assertSet('state', $recipe->state) + ->set('cooking_time', $recipe->cooking_time) + ->assertSet('cooking_time', $recipe->cooking_time) + ->set('ingredients', $recipe->ingredients) + ->assertSet('ingredients', $recipe->ingredients) + ->set('type', $recipe->type) + ->assertSet('type', $recipe->type) + ->set('description', $recipe->description) + ->assertSet('description', $recipe->description) + ->set('video_url', $recipe->video_url) + ->assertSet('video_url', $recipe->video_url) + ->call('publish') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + // check data after update recipe + self::assertEquals($recipe->title, $recipeUpdate->title); + self::assertEquals($recipe->image, $recipeUpdate->image); + self::assertEquals($recipe->state, $recipeUpdate->state); + self::assertEquals($recipe->cooking_time, $recipeUpdate->cooking_time); + self::assertEquals($recipe->ingredients, $recipeUpdate->ingredients); + self::assertEquals($recipe->type, $recipeUpdate->type); + self::assertEquals($recipe->description, $recipeUpdate->description); + self::assertEquals($recipe->video_url, $recipeUpdate->video_url); + } + + + public function testUpdateRecipeDraftSuccess(): void + { + $this->actingAs($this->user); + + $recipe = $this->recipe = Recipe::factory()->make(); + + $recipeUpdate = Livewire::test(Edit::class, [ + 'recipe' => $this->recipe, + ]) + ->set('title', $recipe->title) + ->assertSet('title', $recipe->title) + ->set('image', $recipe->image) + ->set('state', $recipe->state) + ->assertSet('state', $recipe->state) + ->set('cooking_time', $recipe->cooking_time) + ->assertSet('cooking_time', $recipe->cooking_time) + ->set('ingredients', $recipe->ingredients) + ->assertSet('ingredients', $recipe->ingredients) + ->set('type', $recipe->type) + ->assertSet('type', $recipe->type) + ->set('description', $recipe->description) + ->assertSet('description', $recipe->description) + ->set('video_url', $recipe->video_url) + ->assertSet('video_url', $recipe->video_url) + ->call('draft') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + // check data after update recipe + self::assertEquals($recipe->title, $recipeUpdate->title); + self::assertEquals($recipe->image, $recipeUpdate->image); + self::assertEquals('archived', $recipeUpdate->state); + self::assertEquals($recipe->cooking_time, $recipeUpdate->cooking_time); + self::assertEquals($recipe->ingredients, $recipeUpdate->ingredients); + self::assertEquals($recipe->type, $recipeUpdate->type); + self::assertEquals($recipe->description, $recipeUpdate->description); + self::assertEquals($recipe->video_url, $recipeUpdate->video_url); + } + + + public function testUpdateRecipePreviewSuccess(): void + { + $this->actingAs($this->user); + + $recipe = $this->recipe = Recipe::factory()->make(); + + $recipeUpdate = Livewire::test(Edit::class, [ + 'recipe' => $this->recipe, + ]) + ->set('title', $recipe->title) + ->assertSet('title', $recipe->title) + ->set('image', $recipe->image) + ->set('state', $recipe->state) + ->assertSet('state', $recipe->state) + ->set('cooking_time', $recipe->cooking_time) + ->assertSet('cooking_time', $recipe->cooking_time) + ->set('ingredients', $recipe->ingredients) + ->assertSet('ingredients', $recipe->ingredients) + ->set('type', $recipe->type) + ->assertSet('type', $recipe->type) + ->set('description', $recipe->description) + ->assertSet('description', $recipe->description) + ->set('video_url', $recipe->video_url) + ->assertSet('video_url', $recipe->video_url) + ->call('preview') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + // check data after update recipe + self::assertEquals($recipe->title, $recipeUpdate->title); + self::assertEquals($recipe->image, $recipeUpdate->image); + self::assertEquals('archived', $recipeUpdate->state); + self::assertEquals($recipe->cooking_time, $recipeUpdate->cooking_time); + self::assertEquals($recipe->ingredients, $recipeUpdate->ingredients); + self::assertEquals($recipe->type, $recipeUpdate->type); + self::assertEquals($recipe->description, $recipeUpdate->description); + self::assertEquals($recipe->video_url, $recipeUpdate->video_url); + } + + + public function testNothingChange(): void + { + $this->actingAs($this->user); + + $recipeUpdate = Livewire::test(Edit::class, [ + 'recipe' => $this->recipe, + ]) + ->call('publish') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + // check data after update recipe + self::assertEquals($this->recipe->title, $recipeUpdate->title); + self::assertEquals($this->recipe->image, $recipeUpdate->image); + self::assertEquals($this->recipe->state, $recipeUpdate->state); + self::assertEquals($this->recipe->cooking_time, $recipeUpdate->cooking_time); + self::assertEquals($this->recipe->ingredients, $recipeUpdate->ingredients); + self::assertEquals($this->recipe->type, $recipeUpdate->type); + self::assertEquals($this->recipe->description, $recipeUpdate->description); + self::assertEquals($this->recipe->video_url, $recipeUpdate->video_url); + } + +} From 2551aadc7e25077a8c3908c53ea9158c73f00413 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 10:42:40 +0300 Subject: [PATCH 18/24] added edit page recipe --- app/Livewire/Recipe/Edit.php | 45 +- .../views/livewire/recipe/edit.blade.php | 462 +++++++++++------- 2 files changed, 308 insertions(+), 199 deletions(-) diff --git a/app/Livewire/Recipe/Edit.php b/app/Livewire/Recipe/Edit.php index 001f695..928b244 100644 --- a/app/Livewire/Recipe/Edit.php +++ b/app/Livewire/Recipe/Edit.php @@ -17,6 +17,10 @@ class Edit extends Component public $state = 'active'; + public $state_ingredient = 'active'; + + public $state_article = 'active'; + public $type = 'other'; public $tags; @@ -39,6 +43,8 @@ class Edit extends Component public $ingredients_unit = 'gr'; + public $state_row = ['ingredient' => 'true', 'article' => 'false']; + protected $listeners = ['stepRemoved' => '$refresh', 'parentComponentTagAdded', 'parentComponentTagRemoved']; public function mount(Recipe $recipe) @@ -56,14 +62,15 @@ class Edit extends Component $this->video_url = $recipe->video_url; } - public function render() + public function toggleStateRow(string $currentRow): void { - return view('livewire.recipe.edit'); + collect($this->state_row)->keys()->map(fn($key) => $key === $currentRow + ? $this->state_row[$currentRow] = 'true' + : $this->state_row[$key] = 'false'); } public function addIngredient() { - // $this->ingredients[] = ['name' => '', 'portion' => '']; $this->ingredients[] = [ 'name' => $this->ingredients_name, 'portion' => $this->ingredients_portion, @@ -115,6 +122,19 @@ class Edit extends Component $this->recipe->tags()->detach($selectedTags); } + protected function rules() + { + return [ + 'image' => 'filled', + 'state' => 'required|in:active,archived', + 'description' => 'required|min:3', + 'type' => 'required|min:3', + 'video_url' => 'nullable|url|max:2048', + 'cooking_time' => 'nullable|numeric', + ]; + } + + public function draft() { $this->state = 'archived'; @@ -150,18 +170,6 @@ class Edit extends Component return redirect()->route('recipe.show', $recipe->id); } - protected function rules() - { - return [ - 'image' => 'filled', - 'state' => 'required|in:active,archived', - 'description' => 'required|min:3', - 'type' => 'required|min:3', - 'video_url' => 'nullable|url|max:2048', - 'cooking_time' => 'nullable|numeric', - ]; - } - private function transformSteps($steps) { return collect($steps)-> @@ -176,4 +184,11 @@ class Edit extends Component return $data; })->toArray(); } + + + public function render() + { + return view('livewire.recipe.edit'); + } + } diff --git a/resources/views/livewire/recipe/edit.blade.php b/resources/views/livewire/recipe/edit.blade.php index 13fee5f..42e9112 100644 --- a/resources/views/livewire/recipe/edit.blade.php +++ b/resources/views/livewire/recipe/edit.blade.php @@ -26,197 +26,279 @@
-
-
{{ __('recipe.picture') }}
- - @error('image') {{ $message }} @enderror -
-
-
-
- Тип записи -
-
- - -
-
-
-
+
{{ __('recipe.picture') }}
+ + @error('image') + {{ $message }} + @enderror +
+
-
{{ __('recipe.cooking_time') }}
- -
-
-
-
{{ __('recipe.record_state') }}
- -
-
- @php $n = count($ingredients); $lastIngedient = $n-1; @endphp - @if($n == 0) -
-
-
- -
-
-
+
+ + +
+ + {{--
--}} + {{-- --}} + {{-- --}} + {{--
--}} + +
+
+
$state_row['ingredient'] !== 'true', + ]) role="tabpanel" id="tabpanel-1" tabindex="0" + aria-labelledby="tab-1"> +
+
+
{{ __('recipe.cooking_time') }}
+ +
+
+
+
+
{{ __('recipe.record_state') }}
+ +
+
+ @php + $n = count($ingredients); + $lastIngedient = $n - 1; + @endphp + @if ($n == 0) +
+
+
+ +
- -
+
+
+ +
+ +
+ + +
+
+
+
+
+ @endif + @foreach ($ingredients as $k => $ingredient) +
+
+
+ +
- - +
+
+ +
+
+ + @if ($k == count($ingredients) - 1) + + @endif +
+ +
-
+ @endforeach
- @endif - @foreach($ingredients as $k => $ingredient) -
-
-
- -
-
-
-
- -
-
- - @if($k == count($ingredients)-1) - - @endif -
- -
-
-
-
- @endforeach -
-
-
-
-
- Статус -
- + +
$state_row['article'] !== 'true', + ]) role="tabpanel" id="tabpanel-2" tabindex="0" + aria-labelledby="tab-2"> +
+
+
{{ __('recipe.record_state') }}
+ +
+
+
+ +
+
+
+
+ Статус +
+ +
+
-
-
-
{!! $description !!}
+
+ {!! $description !!}
@php $stepsCount = count($steps); @endphp - @for($i = 0; $i < $stepsCount; $i++) + @for ($i = 0; $i < $stepsCount; $i++)
{{ __('recipe.step') }} {{ $i + 1 }} @@ -230,8 +312,12 @@ @if (isset($steps[$i]['image']) && is_string($steps[$i]['image'])) @endif - - @error('steps.'. $i . '.image') {{ $message }} @enderror + + @error('steps.' . $i . '.image') + {{ $message }} + @enderror @if (!isset($steps[$i]['image']))
@@ -241,10 +327,15 @@ @endif - +
- - + +
@@ -259,20 +350,23 @@
{{ __('recipe.video_link') }}
- +
- - - + + +
-
- @foreach ($errors->all() as $message) -
{{ $message }}
- @endforeach -
+
+ @foreach ($errors->all() as $message) +
{{ $message }}
+ @endforeach +
- From bd4566d078c9425dfa51e89b803bddfb4eb27651 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 12:23:13 +0300 Subject: [PATCH 19/24] rename scopes comment --- app/Models/Plan.php | 4 ++-- app/Models/Recipe.php | 7 ++++--- resources/views/livewire/plan/comment/show.blade.php | 4 ++-- resources/views/livewire/recipe/comment/show.blade.php | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) mode change 100644 => 100755 app/Models/Recipe.php diff --git a/app/Models/Plan.php b/app/Models/Plan.php index c9b3bf1..2167a42 100644 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -134,12 +134,12 @@ class Plan extends Model implements Viewable return false; } - public function scopeByNegative(Builder $query) + public function scopeNegativeComments(Builder $query) { return static::comments()->where('grade', '<=', '3'); } - public function scopeByPositive(Builder $query) + public function scopePositiveComments(Builder $query) { return static::comments()->where('grade', '>', '3'); } diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php old mode 100644 new mode 100755 index 83959d6..1e57bc4 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -7,8 +7,8 @@ use CyrildeWit\EloquentViewable\InteractsWithViews; use Illuminate\Database\Eloquent\Casts\AsCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Contracts\Database\Eloquent\Builder; class Recipe extends Model implements Viewable { @@ -57,12 +57,13 @@ class Recipe extends Model implements Viewable return $this->hasMany(RecipeLike::class); } - public function scopeByNegative(Builder $query) + + public function scopeNegativeComments(Builder $query) { return static::comments()->where('grade', '<=', '3'); } - public function scopeByPositive(Builder $query) + public function scopePositiveComments(Builder $query) { return static::comments()->where('grade', '>', '3'); } diff --git a/resources/views/livewire/plan/comment/show.blade.php b/resources/views/livewire/plan/comment/show.blade.php index 5282a0a..504e478 100644 --- a/resources/views/livewire/plan/comment/show.blade.php +++ b/resources/views/livewire/plan/comment/show.blade.php @@ -1,8 +1,8 @@
@php - $positivComments = $plan->byPositive(); + $positivComments = $plan->positiveComments(); - $negativeComments = $plan->byNegative(); + $negativeComments = $plan->negativeComments(); $positiveCommmentsCount = $positivComments->count(); diff --git a/resources/views/livewire/recipe/comment/show.blade.php b/resources/views/livewire/recipe/comment/show.blade.php index 3308310..8573f9b 100644 --- a/resources/views/livewire/recipe/comment/show.blade.php +++ b/resources/views/livewire/recipe/comment/show.blade.php @@ -1,8 +1,8 @@
@php - $positivComments = $recipe->byPositive(); + $positivComments = $recipe->positiveComments(); - $negativeComments = $recipe->byNegative(); + $negativeComments = $recipe->negativeComments(); $positiveCommmentsCount = $positivComments->count(); From fdca3f8b56ff01969b88e7cf9aed86aa28ca6a6f Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 12:39:40 +0300 Subject: [PATCH 20/24] added slug to recipe --- app/Models/Recipe.php | 27 +++++++++++++++++- .../2023_12_25_123200_add_slug_to_recipe.php | 28 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2023_12_25_123200_add_slug_to_recipe.php diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 1e57bc4..b7250ff 100755 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -9,10 +9,14 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Contracts\Database\Eloquent\Builder; +use Spatie\Sluggable\HasSlug; +use Spatie\Sluggable\SlugOptions; class Recipe extends Model implements Viewable { - use HasFactory, InteractsWithViews; + use HasFactory; + use InteractsWithViews; + use HasSlug; protected $casts = [ 'steps' => AsCollection::class, @@ -24,6 +28,27 @@ class Recipe extends Model implements Viewable 'comments', ]; + public function getSlugOptions(): SlugOptions + { + return SlugOptions::create() + ->generateSlugsFrom(['title']) + ->saveSlugsTo('slug') + // ->slugsShouldBeNoLongerThan(20) + ->usingSeparator('_'); + // ->usingLanguage('ru') + // ->doNotGenerateSlugsOnUpdate(); + } + + /** + * Get the route key for the model. + * + * @return string + */ + public function getRouteKeyName() + { + return 'slug'; + } + public function tags() { return $this->morphToMany(Tag::class, 'taggable'); diff --git a/database/migrations/2023_12_25_123200_add_slug_to_recipe.php b/database/migrations/2023_12_25_123200_add_slug_to_recipe.php new file mode 100644 index 0000000..0b3b89f --- /dev/null +++ b/database/migrations/2023_12_25_123200_add_slug_to_recipe.php @@ -0,0 +1,28 @@ +string('slug'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('recipes', function (Blueprint $table) { + $table->dropColumn('slug'); + }); + } +}; From e71ad2e0a05d5e88a3e0c0a8a0d71516e11c9fce Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 13:28:11 +0300 Subject: [PATCH 21/24] added tags factory --- database/factories/TagsFactory.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/factories/TagsFactory.php diff --git a/database/factories/TagsFactory.php b/database/factories/TagsFactory.php new file mode 100644 index 0000000..bf9fc7a --- /dev/null +++ b/database/factories/TagsFactory.php @@ -0,0 +1,28 @@ + + */ +class TagsFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $faker = \Faker\Factory::create(); + $this->faker->addProvider(new Restaurant($faker)); + return [ + 'name' => $this->faker->foodName(), + ]; + } +} From d544d33df923b4862030d40c408b65f7d825d2fb Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 14:08:10 +0300 Subject: [PATCH 22/24] rename tagFactory --- database/factories/{TagsFactory.php => TagFactory.php} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename database/factories/{TagsFactory.php => TagFactory.php} (91%) diff --git a/database/factories/TagsFactory.php b/database/factories/TagFactory.php similarity index 91% rename from database/factories/TagsFactory.php rename to database/factories/TagFactory.php index bf9fc7a..5bb5ba1 100644 --- a/database/factories/TagsFactory.php +++ b/database/factories/TagFactory.php @@ -8,9 +8,9 @@ use Illuminate\Database\Eloquent\Factories\Factory; use FakerRestaurant\Provider\en_US\Restaurant; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PlanComment> + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Tag> */ -class TagsFactory extends Factory +class TagFactory extends Factory { /** * Define the model's default state. From 8f9fe365740d1796877f4b4193c5d617911350e9 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 14:13:06 +0300 Subject: [PATCH 23/24] added tag seeder --- database/seeders/RecipeTagSeeder.php | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 database/seeders/RecipeTagSeeder.php diff --git a/database/seeders/RecipeTagSeeder.php b/database/seeders/RecipeTagSeeder.php new file mode 100644 index 0000000..e78ed35 --- /dev/null +++ b/database/seeders/RecipeTagSeeder.php @@ -0,0 +1,30 @@ + 0) { + $recipes = Recipe::all(); + + $recipes->each(static function ($recipe): void { + + $tags = Tag::factory()->count(5)->create(); + + $tagsIds = collect($tags)->map(fn($curTag) => $curTag['id']); + $recipe->tags()->attach($tagsIds); + }); + } + } +} From c4bd75989533c5b3edfc6079b25034f942d0d8af Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 25 Dec 2023 14:13:25 +0300 Subject: [PATCH 24/24] added tag seeder to database seeder --- database/seeders/DatabaseSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index b4935ee..0be680a 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -17,5 +17,6 @@ class DatabaseSeeder extends Seeder $this->call(RecipeSeeder::class); $this->call(RecipeAuthor::class); $this->call(RecipeCommentSeeder::class); + $this->call(RecipeTagSeeder::class); } }