diff --git a/app/Http/Middleware/InitVarsGlobals.php b/app/Http/Middleware/InitVarsGlobals.php index 1124288..b9040c3 100644 --- a/app/Http/Middleware/InitVarsGlobals.php +++ b/app/Http/Middleware/InitVarsGlobals.php @@ -57,8 +57,10 @@ class InitVarsGlobals ])->first(); // Limitation à 3 produits affichés sur la homepage $products_home = Product::where('is_on_top', true)->take(3)->get(); - // Limitation à 6 produits affichés sur la page Food Service - $products_food = Product::where('is_food_service', true)->take(6)->get(); + // produits affichés sur la page news + $products_news = Product::where('is_news', true)->get(); + // Produits affichés sur la page Food Service + $products_food = Product::where('is_food_service', true)->get(); $pictos_marqueBloc2 = Picto::where('page', Page::marqueBloc2()->value)->get(); $pictos_food = Picto::where('page', Page::foodBloc2()->value)->get(); @@ -87,6 +89,7 @@ class InitVarsGlobals View::share('posts', $posts); View::share('products_home', $products_home); + View::share('products_news', $products_news); View::share('products_food', $products_food); View::share('advice_news', $advice_news); diff --git a/app/Http/Requests/StoreProductRequest.php b/app/Http/Requests/StoreProductRequest.php index e4f440e..76e5bb7 100644 --- a/app/Http/Requests/StoreProductRequest.php +++ b/app/Http/Requests/StoreProductRequest.php @@ -150,6 +150,7 @@ class StoreProductRequest extends FormRequest 'plusproduit' => $tabPlusProduit, 'is_published' => $this->is_published ? true : false, 'is_on_top' => $this->is_on_top ? true : false, + 'is_news' => $this->is_news ? true : false, 'is_food_service' => $this->is_food_service ? true : false, 'is_halal' => $this->is_halal ? true : false, ]); @@ -180,6 +181,7 @@ class StoreProductRequest extends FormRequest 'pictogramme2' => 'nullable|image|mimes:png|max:1024|dimensions:width=141,height=100', 'is_published' => 'nullable|boolean', 'is_on_top' => 'nullable|boolean', + 'is_news' => 'nullable|boolean', 'is_food_service' => 'nullable|boolean', 'is_halal' => 'nullable|boolean', // 'seo_title' => 'required|max:255', diff --git a/app/Models/Product.php b/app/Models/Product.php index b4cd42f..995915b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -24,6 +24,7 @@ class Product extends Model 'plusproduit', 'is_published', 'is_on_top', + 'is_news', 'is_halal', 'is_food_service', 'seo_title', diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index 8e37616..ae4fecf 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -130,6 +130,7 @@ class ProductFactory extends Factory 'plusproduit' => json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]), 'is_published' => true, 'is_on_top' => rand(true, false), + 'is_news' => rand(true, false), 'is_food_service' => rand(true, false), 'is_halal' => rand(true, false), 'seo_title' => $this->faker->text(5), diff --git a/database/migrations/2022_05_12_101807_add_is_news_on_products.php b/database/migrations/2022_05_12_101807_add_is_news_on_products.php new file mode 100644 index 0000000..79a8bbe --- /dev/null +++ b/database/migrations/2022_05_12_101807_add_is_news_on_products.php @@ -0,0 +1,32 @@ +boolean('is_news')->after('is_on_top'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('products', function (Blueprint $table) { + $table->dropColumn('is_news'); + }); + } +} diff --git a/database/seeders/GammesSeeder.php b/database/seeders/GammesSeeder.php index 3fa08c0..6d16be5 100644 --- a/database/seeders/GammesSeeder.php +++ b/database/seeders/GammesSeeder.php @@ -162,6 +162,7 @@ class GammesSeeder extends Seeder $product->plusproduit = json_encode([$tabPlusProduit1, $tabPlusProduit2]); $product->is_published = true; $product->is_on_top = rand(true, false); + $product->is_news = rand(true, false); $product->is_food_service = rand(true, false); $product->is_halal = rand(true, false); $product->seo_title = 'Chicken franks, poulet, recettes, qualité'; @@ -226,6 +227,7 @@ class GammesSeeder extends Seeder $product->plusproduit = json_encode([$tabPlusProduit1, $tabPlusProduit2]); $product->is_published = true; $product->is_on_top = rand(true, false); + $product->is_news = rand(true, false); $product->is_food_service = rand(true, false); $product->is_halal = rand(true, false); $product->seo_title = 'recette, qualité, Chicken franks, plaisir, gourmandise'; @@ -254,6 +256,7 @@ class GammesSeeder extends Seeder $product->plusproduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]); $product->is_published = true; $product->is_on_top = rand(true, false); + $product->is_news = rand(true, false); $product->is_food_service = rand(true, false); $product->is_halal = rand(true, false); $product->seo_title = 'recette, qualité, Chicken franks, plaisir, gourmandise'; @@ -312,6 +315,7 @@ class GammesSeeder extends Seeder $product->plusproduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]); $product->is_published = true; $product->is_on_top = rand(true, false); + $product->is_news = rand(true, false); $product->is_food_service = rand(true, false); $product->is_halal = rand(true, false); $product->seo_title = 'recette, qualité, viande, cuisse, steak haché, poulet'; @@ -351,6 +355,7 @@ class GammesSeeder extends Seeder $product->plusproduit = json_encode([$tabPlusProduit1]); $product->is_published = true; $product->is_on_top = rand(true, false); + $product->is_news = rand(true, false); $product->is_food_service = rand(true, false); $product->is_halal = rand(true, false); $product->seo_title = 'volaille, poulet, Doux, qualités'; diff --git a/resources/views/back/products/form-inputs.blade.php b/resources/views/back/products/form-inputs.blade.php index 73646da..50fca22 100644 --- a/resources/views/back/products/form-inputs.blade.php +++ b/resources/views/back/products/form-inputs.blade.php @@ -132,6 +132,11 @@ $plusproduit = json_decode($product->plusproduit); @include('back.modules.input-error', ['inputName'=>'is_on_top']) +
{{ __('Nous travaillons toujours pour améliorer nos recettes et proposer des produits de meilleure qualité')}}
- @if (isset($products_home)) + @if (isset($products_news))