From 4122e3e135d214ea6eb1110c73712cf6b93a05c8 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 14 Dec 2023 15:19:47 +0300 Subject: [PATCH 01/14] Added seeder for Recipe and registered in DatabaseSeeder --- database/seeders/DatabaseSeeder.php | 1 + database/seeders/RecipeSeeder.php | 49 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 database/seeders/RecipeSeeder.php diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a8222ee..a346b78 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -16,6 +16,7 @@ class DatabaseSeeder extends Seeder { $this->call(PlanSeeder::class); $this->call(UserSeeder::class); + $this->call(RecipeSeeder::class); // \App\Models\User::factory(10)->create(); } } diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php new file mode 100644 index 0000000..23724b1 --- /dev/null +++ b/database/seeders/RecipeSeeder.php @@ -0,0 +1,49 @@ +image = $faker->imageUrl(640, 480, 'food'); + $recipe->state = 'active'; + $recipe->type = $faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']); + $recipe->title = $faker->sentence(5); + $recipe->video_url = $faker->url; + $recipe->cooking_time = $faker->randomElement([10,20,30,60,120,14400]); + $recipe->description = $faker->text(200); + $recipe->steps = [ + ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], + ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], + ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)] + ]; + $recipe->ingredients = [ + ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], + ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], + ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], + ]; + $recipe->save(); + DB::table('recipe_author')->insert([ + 'recipe_id' => $recipe->id, + 'user_id' => 3 + ]); + } + + } +} From 1aaa7964ca54304cb9deb59b1a2b453ef1a01d2d Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 14 Dec 2023 15:23:37 +0300 Subject: [PATCH 02/14] Author is now random --- database/seeders/RecipeSeeder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 23724b1..9a81c00 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -6,6 +6,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use App\Models\Recipe; use App\Models\RecipeAuthor; +use App\Models\User; use Faker\Factory as FakerFaktory; use DB; @@ -41,7 +42,7 @@ class RecipeSeeder extends Seeder $recipe->save(); DB::table('recipe_author')->insert([ 'recipe_id' => $recipe->id, - 'user_id' => 3 + 'user_id' => User::inRandomOrder()->first()->id ]); } From ee3a6e21423144155661bcba095778425b685e31 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 14 Dec 2023 16:07:55 +0300 Subject: [PATCH 03/14] Removed direct database query, used attach() method on User instead --- database/seeders/RecipeSeeder.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 9a81c00..b92f020 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -40,11 +40,7 @@ class RecipeSeeder extends Seeder ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], ]; $recipe->save(); - DB::table('recipe_author')->insert([ - 'recipe_id' => $recipe->id, - 'user_id' => User::inRandomOrder()->first()->id - ]); + User::inRandomOrder()->first()->author_of_recipe()->attach($recipe->id); } - } } From b782272d9832e129f07f14febb53171b62f08376 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Fri, 15 Dec 2023 10:47:19 +0300 Subject: [PATCH 04/14] Seeder images --- database/seeders/RecipeSeeder.php | 25 ++++++++++++++----- .../views/livewire/recipe/list-view.blade.php | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index b92f020..c4fb37f 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -7,7 +7,7 @@ use Illuminate\Database\Seeder; use App\Models\Recipe; use App\Models\RecipeAuthor; use App\Models\User; -use Faker\Factory as FakerFaktory; +use Faker\Factory as FakerFactory; use DB; class RecipeSeeder extends Seeder @@ -19,10 +19,11 @@ class RecipeSeeder extends Seeder */ public function run() { - $faker = FakerFaktory::create(); + $faker = FakerFactory::create(); + $images = []; for ($i = 0; $i < 10; $i++) { $recipe = new Recipe(); - $recipe->image = $faker->imageUrl(640, 480, 'food'); + $recipe->image = $this->downloadRandomImage(); $recipe->state = 'active'; $recipe->type = $faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']); $recipe->title = $faker->sentence(5); @@ -30,9 +31,9 @@ class RecipeSeeder extends Seeder $recipe->cooking_time = $faker->randomElement([10,20,30,60,120,14400]); $recipe->description = $faker->text(200); $recipe->steps = [ - ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], - ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)], - ['image' => $faker->imageUrl(640, 480, 'food'), 'description' => $faker->text(100)] + ['image' => $this->downloadRandomImage(), 'description' => $faker->text(100)], + ['image' => $this->downloadRandomImage(), 'description' => $faker->text(100)], + ['image' => $this->downloadRandomImage(), 'description' => $faker->text(100)] ]; $recipe->ingredients = [ ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], @@ -42,5 +43,17 @@ class RecipeSeeder extends Seeder $recipe->save(); User::inRandomOrder()->first()->author_of_recipe()->attach($recipe->id); } + + + } + public function downloadRandomImage(): string + { + $faker = FakerFactory::create(); + $url = $faker->imageUrl(640, 480, 'food', true); + $contents = file_get_contents($url); + $path = 'recipe/' . uniqid() . '.jpg'; + file_put_contents(storage_path('app/public/' . $path), $contents); + + return $path; } } diff --git a/resources/views/livewire/recipe/list-view.blade.php b/resources/views/livewire/recipe/list-view.blade.php index e6e5a37..9deff42 100644 --- a/resources/views/livewire/recipe/list-view.blade.php +++ b/resources/views/livewire/recipe/list-view.blade.php @@ -27,7 +27,7 @@ @if(is_null($image)) formats @else - recipe + recipe @endif From 8b417a9ff5b0b6108bb0b82d4f8b954f3e912657 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Fri, 15 Dec 2023 10:48:36 +0300 Subject: [PATCH 05/14] Seeder minor fix --- resources/views/livewire/recipe/list-view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/recipe/list-view.blade.php b/resources/views/livewire/recipe/list-view.blade.php index 9deff42..e6e5a37 100644 --- a/resources/views/livewire/recipe/list-view.blade.php +++ b/resources/views/livewire/recipe/list-view.blade.php @@ -27,7 +27,7 @@ @if(is_null($image)) formats @else - recipe + recipe @endif From 14e0f36e7646f5b115a861a41b1034031d71cf2b Mon Sep 17 00:00:00 2001 From: maxxkim Date: Fri, 15 Dec 2023 11:56:03 +0300 Subject: [PATCH 06/14] Path exists validation --- database/seeders/RecipeSeeder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index c4fb37f..939c789 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -51,7 +51,11 @@ class RecipeSeeder extends Seeder $faker = FakerFactory::create(); $url = $faker->imageUrl(640, 480, 'food', true); $contents = file_get_contents($url); + $dir_path = storage_path('app/public/recipe'); $path = 'recipe/' . uniqid() . '.jpg'; + if (!file_exists( $dir_path)) { + mkdir( $dir_path, 0777, true); + } file_put_contents(storage_path('app/public/' . $path), $contents); return $path; From e887e5eae132fabbb21b33244dc8a8b58f5fa121 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Fri, 15 Dec 2023 14:04:01 +0300 Subject: [PATCH 07/14] Added comments to RecipeSeeder --- database/seeders/RecipeSeeder.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 939c789..5120977 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Storage; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use App\Models\Recipe; +use App\Models\RecipeComment; use App\Models\RecipeAuthor; use App\Models\User; use Faker\Factory as FakerFactory; @@ -41,6 +42,14 @@ class RecipeSeeder extends Seeder ['name' => $faker->word, 'portion' => $faker->numberBetween(1, 20), 'unit' => $faker->randomElement(['teespoon', 'tablespoon', 'ml', 'pcs', 'clove', 'to_taste'])], ]; $recipe->save(); + for ($j = 0; $j < 10; $j++) { + $comment = new RecipeComment(); + $comment->user_id = User::inRandomOrder()->first()->id; + $comment->recipe_id = $recipe->id; + $comment->grade = $faker->randomElement([1,2,3,4,5]); + $comment->body = $faker->text(100); + $comment->save(); + } User::inRandomOrder()->first()->author_of_recipe()->attach($recipe->id); } From d0384287b9d1b041a38baf8b66718d173aaffbaf Mon Sep 17 00:00:00 2001 From: apoloz Date: Fri, 15 Dec 2023 13:46:06 +0000 Subject: [PATCH 08/14] fix stock auth layouts --- resources/views/auth/confirm-password.blade.php | 3 +++ resources/views/auth/forgot-password.blade.php | 3 +++ resources/views/auth/login.blade.php | 4 ++++ resources/views/auth/register.blade.php | 3 +++ resources/views/auth/reset-password.blade.php | 3 +++ resources/views/auth/two-factor-challenge.blade.php | 3 +++ resources/views/auth/verify-email.blade.php | 3 +++ resources/views/layouts/guest.blade.php | 1 + 8 files changed, 23 insertions(+) diff --git a/resources/views/auth/confirm-password.blade.php b/resources/views/auth/confirm-password.blade.php index ccc4b28..33905ff 100644 --- a/resources/views/auth/confirm-password.blade.php +++ b/resources/views/auth/confirm-password.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/auth/forgot-password.blade.php b/resources/views/auth/forgot-password.blade.php index 0097654..aba7922 100644 --- a/resources/views/auth/forgot-password.blade.php +++ b/resources/views/auth/forgot-password.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 0c5902d..991b1ef 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,4 +1,8 @@ + + @push('css_head') + + @endpush diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 8a5f240..6681119 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/auth/reset-password.blade.php b/resources/views/auth/reset-password.blade.php index 5991e3e..daeee33 100644 --- a/resources/views/auth/reset-password.blade.php +++ b/resources/views/auth/reset-password.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/auth/two-factor-challenge.blade.php b/resources/views/auth/two-factor-challenge.blade.php index eec9264..da87857 100644 --- a/resources/views/auth/two-factor-challenge.blade.php +++ b/resources/views/auth/two-factor-challenge.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/auth/verify-email.blade.php b/resources/views/auth/verify-email.blade.php index 59669c6..0ec4cbc 100644 --- a/resources/views/auth/verify-email.blade.php +++ b/resources/views/auth/verify-email.blade.php @@ -1,4 +1,7 @@ + @push('css_head') + + @endpush diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index fa10db7..1f7f378 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -16,6 +16,7 @@ + @stack('css_head') @livewireStyles From 6c48c062a4f2768364166b8c73a7c50d55aaa8b8 Mon Sep 17 00:00:00 2001 From: apoloz Date: Fri, 15 Dec 2023 14:53:43 +0000 Subject: [PATCH 09/14] fix app layout --- resources/views/blog_post/index.blade.php | 6 ++++++ resources/views/chat/index.blade.php | 6 ++++++ resources/views/consultant/index.blade.php | 2 ++ resources/views/consultant/list.blade.php | 5 +++++ resources/views/diet/index.blade.php | 6 ++++++ resources/views/plan/index.blade.php | 5 +++++ resources/views/profile/index.blade.php | 5 +++++ resources/views/recipe/index.blade.php | 9 ++++++--- 8 files changed, 41 insertions(+), 3 deletions(-) diff --git a/resources/views/blog_post/index.blade.php b/resources/views/blog_post/index.blade.php index a676513..6fc52c6 100644 --- a/resources/views/blog_post/index.blade.php +++ b/resources/views/blog_post/index.blade.php @@ -8,3 +8,9 @@ @endpush +@push('css_head') + + + +@endpush + diff --git a/resources/views/chat/index.blade.php b/resources/views/chat/index.blade.php index f7a1289..d4e3f9b 100644 --- a/resources/views/chat/index.blade.php +++ b/resources/views/chat/index.blade.php @@ -1,5 +1,11 @@ @extends('layouts/eatvio') @section('page_title', 'Chat') +@push('css_head') + + + +@endpush + @section('main_section')
diff --git a/resources/views/consultant/index.blade.php b/resources/views/consultant/index.blade.php index 42d1a5f..5c1a6dd 100644 --- a/resources/views/consultant/index.blade.php +++ b/resources/views/consultant/index.blade.php @@ -1,4 +1,6 @@ @extends('layouts/eatvio') + + @section('main_section')
diff --git a/resources/views/consultant/list.blade.php b/resources/views/consultant/list.blade.php index 42d1a5f..855ffac 100644 --- a/resources/views/consultant/list.blade.php +++ b/resources/views/consultant/list.blade.php @@ -1,4 +1,9 @@ @extends('layouts/eatvio') +@push('css_head') + + + +@endpush @section('main_section')
diff --git a/resources/views/diet/index.blade.php b/resources/views/diet/index.blade.php index 9e1dd9c..8c87b10 100644 --- a/resources/views/diet/index.blade.php +++ b/resources/views/diet/index.blade.php @@ -9,6 +9,12 @@ $mealNames = ['breakfast', 'dinner', 'supper', 'lunch', 'snacks']; @endphp +@push('css_head') + + + +@endpush + @section('main_section')