diff --git a/app/Http/Controllers/ProductsController.php b/app/Http/Controllers/ProductsController.php
index a364dee..8126187 100644
--- a/app/Http/Controllers/ProductsController.php
+++ b/app/Http/Controllers/ProductsController.php
@@ -7,11 +7,12 @@ use App\Models\Product;
class ProductsController extends Controller
{
- // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
+ // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
public function show(Gamme $gamme, Product $product)
{
$product = Product::whereSlug($product->slug)->first();
-
+ // var_dump($product);
+ // exit;
return view('front.product', compact('product', 'gamme'));
}
}
diff --git a/app/Http/Requests/StoreProductRequest.php b/app/Http/Requests/StoreProductRequest.php
index d39d4cc..d0f4292 100644
--- a/app/Http/Requests/StoreProductRequest.php
+++ b/app/Http/Requests/StoreProductRequest.php
@@ -78,36 +78,57 @@ class StoreProductRequest extends FormRequest
'temp' => $this->temp_cook7,
'status' => $this->is_activated7 ? true : false
);
+ $tabCuisson = json_encode([
+ 'four' => $tabFour,
+ 'friteuse' => $tabFriteuse,
+ 'poele' => $tabPoele,
+ 'cocotte' => $tabCocotte,
+ 'plancha' => $tabPlancha,
+ 'bainmarie' => $tabBainMarie,
+ 'barbecue' => $tabBarbecue,
+ 'microondes' => $tabMicroOndes
+ ]);
+
+ // var_dump(public_path() . "\assets\images\sans-label.jpg");
+ // var_dump(storage_path('app\public'));
+ // var_dump(pathinfo(storage_path('app\public')));
+ // exit;
+ // TODO storage json pictures
+
+ $urlPlusProduit = "/assets/images/sans-label.jpg";
+ if ($this->pictogramme0) {
+ $urlPlusProduit = "/assets/images/" . $this->pictogramme0->getClientOriginalName();
+ }
$tabPlusProduit1 = array(
'id' => 0,
'name' => $this->content0,
- 'url' => '/assets/images/sans-label.jpg',
+ 'url' => $urlPlusProduit,
);
+ $urlPlusProduit = "/assets/images/sans-label.jpg";
+ if ($this->pictogramme1) {
+ $urlPlusProduit = "/assets/images/" . $this->pictogramme1->getClientOriginalName();
+ }
$tabPlusProduit2 = array(
'id' => 1,
'name' => $this->content1,
- 'url' => '/assets/images/sans-label.jpg',
+ 'url' => $urlPlusProduit,
);
+ $urlPlusProduit = "/assets/images/sans-label.jpg";
+ if ($this->pictogramme2) {
+ $urlPlusProduit = "/assets/images/" . $this->pictogramme2->getClientOriginalName();
+ }
$tabPlusProduit3 = array(
'id' => 2,
'name' => $this->content2,
- 'url' => '/assets/images/sans-label.jpg',
+ 'url' => $urlPlusProduit,
);
+ $tabPlusProduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]);
$this->merge([
'slug' => Str::slug($this->name),
'gamme_id' => $this->gamme_id === '0' ? null : $this->gamme_id,
- 'pictos' => json_encode([
- 'four' => $tabFour,
- 'friteuse' => $tabFriteuse,
- 'poele' => $tabPoele,
- 'cocotte' => $tabCocotte,
- 'plancha' => $tabPlancha,
- 'bainmarie' => $tabBainMarie,
- 'barbecue' => $tabBarbecue,
- 'microondes' => $tabMicroOndes
- ]),
- 'plusproduit' => json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]),
+ 'pictos' => $tabCuisson,
+ 'plusproduit' => $tabPlusProduit,
'is_published' => $this->is_published ? true : false,
'is_on_top' => $this->is_on_top ? true : false,
'is_food_service' => $this->is_food_service ? true : false,
diff --git a/app/Models/Advice.php b/app/Models/Advice.php
index e0191aa..4e9382d 100644
--- a/app/Models/Advice.php
+++ b/app/Models/Advice.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class Advice extends Model
{
@@ -48,6 +49,33 @@ class Advice extends Model
$advice->picture3 = Utils::storeImage($advice->picture3, $advice->getTable());
}
});
+
+ static::deleted(function (Advice $advice) {
+ if ($advice->picture1) {
+ $urlPicture = public_path() . $advice->picture1;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ if ($advice->picture2) {
+ $urlPicture = public_path() . $advice->picture2;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ if ($advice->picture3) {
+ $urlPicture = public_path() . $advice->picture3;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/Encart.php b/app/Models/Encart.php
index b9b238a..ad4a3cb 100644
--- a/app/Models/Encart.php
+++ b/app/Models/Encart.php
@@ -6,6 +6,7 @@ use App\Enums\Page;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Encart extends Model
@@ -38,6 +39,17 @@ class Encart extends Model
$encart->picture = Utils::storeImage($encart->picture, $encart->getTable());
}
});
+
+ static::deleted(function (Encart $encart) {
+ if ($encart->picture) {
+ $urlPicture = public_path() . $encart->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/Gamme.php b/app/Models/Gamme.php
index bcfc11f..7c1afc0 100644
--- a/app/Models/Gamme.php
+++ b/app/Models/Gamme.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class Gamme extends Model
{
@@ -63,6 +64,32 @@ class Gamme extends Model
$gamme->color = Gamme::whereId($gamme->parent_gamme_id)->select(['color'])->first()->color;
}
});
+
+ static::deleting(function (Gamme $gamme) {
+ if ($gamme->childGammes()->exists()) {
+ Gamme::whereParentGammeId($gamme->id)
+ ->update(['parent_gamme_id' => null]);
+ }
+ });
+
+ static::deleted(function (Gamme $gamme) {
+ if ($gamme->picture) {
+ $urlPicture = public_path() . $gamme->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ if ($gamme->banner) {
+ $urlPicture = public_path() . $gamme->banner;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
diff --git a/app/Models/Moment.php b/app/Models/Moment.php
index bfbcf78..307a56f 100644
--- a/app/Models/Moment.php
+++ b/app/Models/Moment.php
@@ -6,6 +6,7 @@ use App\Enums\Page;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Moment extends Model
@@ -21,7 +22,7 @@ class Moment extends Model
'title',
'subtitle',
'text',
- 'picture'
+ 'picture',
'alt_text_picture',
];
@@ -38,6 +39,17 @@ class Moment extends Model
$moment->picture = Utils::storeImage($moment->picture, $moment->getTable());
}
});
+
+ static::deleted(function (Moment $moment) {
+ if ($moment->picture) {
+ $urlPicture = public_path() . $moment->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/Picto.php b/app/Models/Picto.php
index e677ed0..db8347f 100644
--- a/app/Models/Picto.php
+++ b/app/Models/Picto.php
@@ -6,6 +6,7 @@ use App\Enums\Page;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Picto extends Model
@@ -36,6 +37,17 @@ class Picto extends Model
$picto->picture = Utils::storeImage($picto->picture, $picto->getTable());
}
});
+
+ static::deleted(function (Picto $picto) {
+ if ($picto->picture) {
+ $urlPicture = public_path() . $picto->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/PictoBrand.php b/app/Models/PictoBrand.php
index b0d292c..7b95261 100644
--- a/app/Models/PictoBrand.php
+++ b/app/Models/PictoBrand.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class PictoBrand extends Model
{
@@ -30,6 +31,17 @@ class PictoBrand extends Model
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
}
});
+
+ static::deleted(function (PictoBrand $pictoBrand) {
+ if ($pictoBrand->picture) {
+ $urlPicture = public_path() . $pictoBrand->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/Post.php b/app/Models/Post.php
index 1ea1029..8080b9c 100644
--- a/app/Models/Post.php
+++ b/app/Models/Post.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class Post extends Model
{
@@ -51,6 +52,25 @@ class Post extends Model
$post->picture_news = Utils::storeImage($post->picture_news, $post->getTable());
}
});
+
+ static::deleted(function (Post $post) {
+ if ($post->picture_home) {
+ $urlPicture = public_path() . $post->picture_home;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ if ($post->picture_news) {
+ $urlPicture = public_path() . $post->picture_news;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
}
diff --git a/app/Models/Product.php b/app/Models/Product.php
index 4405faa..33235b1 100644
--- a/app/Models/Product.php
+++ b/app/Models/Product.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class Product extends Model
{
@@ -46,6 +47,25 @@ class Product extends Model
$product->banner = Utils::storeImage($product->banner, $product->getTable());
}
});
+
+ static::deleted(function (Product $product) {
+ if ($product->picture) {
+ $urlPicture = public_path() . $product->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ if ($product->banner) {
+ $urlPicture = public_path() . $product->banner;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
diff --git a/app/Models/Slide.php b/app/Models/Slide.php
index 399d2a5..f7d97dc 100644
--- a/app/Models/Slide.php
+++ b/app/Models/Slide.php
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Lib\Utils;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\File;
class Slide extends Model
{
@@ -46,6 +47,17 @@ class Slide extends Model
$slide->picture = Utils::storeImage($slide->picture, $slide->getTable());
}
});
+
+ static::deleted(function (Slide $slide) {
+ if ($slide->picture) {
+ $urlPicture = public_path() . $slide->picture;
+ if ($urlPicture) {
+ if (File::exists($urlPicture)) {
+ File::delete($urlPicture);
+ }
+ }
+ }
+ });
parent::boot();
}
diff --git a/app/Models/User.php b/app/Models/User.php
index ee863f5..e239721 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -3,13 +3,11 @@
namespace App\Models;
use App\Enums\Role;
-use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use Kwaadpepper\Enum\Traits\CastsEnums;
-use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php
index 7e644b7..4e89715 100644
--- a/database/factories/ProductFactory.php
+++ b/database/factories/ProductFactory.php
@@ -113,9 +113,9 @@ class ProductFactory extends Factory
]),
'plusproduit' => json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]),
'is_published' => true,
- 'is_on_top' => false,
- 'is_food_service' => false,
- 'is_halal' => true,
+ 'is_on_top' => rand(true, false),
+ 'is_food_service' => rand(true, false),
+ 'is_halal' => rand(true, false),
'seo_title' => $this->faker->text(5),
'seo_description' => $this->faker->sentence(20),
];
diff --git a/public/css/preload-front.css b/public/css/preload-front.css
index 20c94ef..dd07df0 100644
--- a/public/css/preload-front.css
+++ b/public/css/preload-front.css
@@ -4179,6 +4179,18 @@ img{
margin-left:25px;
}
+.product ul.more li{
+ width:-webkit-max-content;
+ width:-moz-max-content;
+ width:max-content;
+}
+.product ul.more li p:first-of-type{
+ font-size:18px;
+}
+.product ul.more li::before{
+ top:30px;
+}
+
ul.more{
margin-top:50px;
}
@@ -4187,21 +4199,20 @@ ul.more li{
position:relative;
padding-left:25px;
margin-bottom:30px;
- width:-webkit-max-content;
- width:-moz-max-content;
- width:max-content;
+ width:100%;
}
ul.more li:last-of-type{
margin-bottom:0;
}
ul.more li p:first-of-type{
position:relative;
+ font-size:26px;
}
ul.more li::before{
content:"";
position:absolute;
left:0;
- top:30px;
+ top:20px;
width:10px;
height:10px;
background-color:#222f5c;
@@ -4263,7 +4274,7 @@ ul.infos span{
padding-top:50px;
}
- ul.more li::before{
+ .product ul.more li::before{
top:10px;
}
}
@@ -4321,6 +4332,10 @@ ul.infos span{
font-weight:bold;
}
+.on-bottom{
+ z-index:-1;
+}
+
.ttu{
text-transform:uppercase;
}
diff --git a/resources/sass/frontend/_globals.scss b/resources/sass/frontend/_globals.scss
index 4551a0c..3e48f14 100644
--- a/resources/sass/frontend/_globals.scss
+++ b/resources/sass/frontend/_globals.scss
@@ -75,6 +75,16 @@ img {
margin-left: 25px;
}
+.product ul.more li {
+ width: max-content;
+
+ p:first-of-type {
+ font-size: 18px;
+ }
+ &::before {
+ top: 30px;
+ }
+}
ul.more {
margin-top: 50px;
@@ -83,19 +93,20 @@ ul.more {
position: relative;
padding-left: 25px;
margin-bottom: 30px;
- width: max-content;
+ width: 100%;
&:last-of-type {
margin-bottom: 0;
}
p:first-of-type {
position: relative;
+ font-size: 26px;
}
&::before {
content: "";
position: absolute;
left: 0;
- top: 30px;
+ top: 20px;
width: 10px;
height: 10px;
background-color: $color-blue;
@@ -159,7 +170,7 @@ ul.infos {
main {
padding-top: 50px;
}
- ul.more li::before {
+ .product ul.more li::before {
top: 10px;
}
}
diff --git a/resources/sass/frontend/_utils.scss b/resources/sass/frontend/_utils.scss
index 9910ce0..3a35c9d 100644
--- a/resources/sass/frontend/_utils.scss
+++ b/resources/sass/frontend/_utils.scss
@@ -11,7 +11,9 @@
.bold {
font-weight: bold;
}
-
+.on-bottom {
+ z-index: -1;
+}
.ttu {
text-transform: uppercase;
}
diff --git a/resources/views/back/products/form-inputs.blade.php b/resources/views/back/products/form-inputs.blade.php
index 8294820..3ae7622 100644
--- a/resources/views/back/products/form-inputs.blade.php
+++ b/resources/views/back/products/form-inputs.blade.php
@@ -109,7 +109,7 @@ $plusproduit = json_decode($product->plusproduit);
@if ($plus->url !== null)
-
+
@endif
@include('back.modules.input-error', ['inputName'=>'pictogramme{{$plus->id}}'])
diff --git a/resources/views/front/gammes/product.blade.php b/resources/views/front/gammes/product.blade.php
index 0d75d20..35b62fa 100644
--- a/resources/views/front/gammes/product.blade.php
+++ b/resources/views/front/gammes/product.blade.php
@@ -1,7 +1,7 @@