diff --git a/app/Http/Controllers/Shop/ArticleController.php b/app/Http/Controllers/Shop/ArticleController.php index 17c80c64..9eb8dd49 100644 --- a/app/Http/Controllers/Shop/ArticleController.php +++ b/app/Http/Controllers/Shop/ArticleController.php @@ -9,79 +9,14 @@ use App\Repositories\Shop\Articles; class ArticleController extends Controller { - /** - * Display a listing of the resource. - * - * @return \Illuminate\Http\Response - */ - public function index() - { - // - } - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\Http\Response - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function store(Request $request) - { - // - } - - /** - * Display the specified resource. - * - * @param \App\Article $article - * @return \Illuminate\Http\Response - */ public function show($id) { - // + $data = self::init(); + $data['article'] = Articles::getArticle($id); + // dump($data); + // exit; + return view('Shop.Articles.show', $data); } - /** - * Show the form for editing the specified resource. - * - * @param \App\Article $article - * @return \Illuminate\Http\Response - */ - public function edit($id) - { - // - } - - /** - * Update the specified resource in storage. - * - * @param \Illuminate\Http\Request $request - * @param \App\Article $article - * @return \Illuminate\Http\Response - */ - public function update(Request $request, $id) - { - // - } - - /** - * Remove the specified resource from storage. - * - * @param \App\Article $article - * @return \Illuminate\Http\Response - */ - public function destroy($id) - { - // - } } diff --git a/app/Repositories/Core/Medias.php b/app/Repositories/Core/Medias.php index b404d3d4..ee02c0fb 100644 --- a/app/Repositories/Core/Medias.php +++ b/app/Repositories/Core/Medias.php @@ -74,6 +74,17 @@ class Medias return '.' . pathinfo($filename, PATHINFO_EXTENSION); } + public static function getImageSrc($image) + { + if (!$image) { + return null; + } + $id = $image['id']; + $filename = $image['name'] . self::getExtension($image['file_name']); + + return "/storage/$id/$filename"; + } + public static function getThumbSrc($image) { if (!$image) { diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index 620dbc5c..b38b4be3 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -51,7 +51,9 @@ class Articles { $article = self::get($id); $data = $article->toArray(); + $data['description'] = (!empty($article->description)) ? $article->description : $article->product->description; $data['image'] = Articles::getPreview($article->image); + $data['image_big'] = Articles::getImage($article->image); $data['inherited'] = self::getInherited($id); $data['categories'] = self::getCategoriesNameByArticle($article); $data['tags'] = self::getTagsNameByArticle($article); @@ -63,6 +65,7 @@ class Articles { $articles = self::getArticlesWithOffers(); // dump($articles->toArray()); + // exit; foreach ($articles as $article) { $price_lists = $article->offers[0]->tariff->price_lists->toArray(); // dump($price_lists); @@ -81,6 +84,7 @@ class Articles 'offer_id' => $article->offers[0]->id, 'quantity' => $prices['quantity'], 'price' => $prices['price_taxed'], + 'variation' => $article->offers[0]->variation->name, ]; } } @@ -95,7 +99,7 @@ class Articles 'image', 'product', 'article_nature', - 'offers.variation', + 'offers.variation.package', 'offers.tariff.price_lists.price_list_values', ])->get(); } diff --git a/app/Traits/Repository/Imageable.php b/app/Traits/Repository/Imageable.php index 39cb47e4..2b21b365 100644 --- a/app/Traits/Repository/Imageable.php +++ b/app/Traits/Repository/Imageable.php @@ -36,6 +36,16 @@ trait Imageable return $image ? Medias::getPreviewSrc($image) : null; } + public static function getImage($image) + { + return ''; + } + + public static function getImageSrc($image) + { + return $image ? Medias::getImageSrc($image) : null; + } + public static function deleteImage($id, $index) { return Medias::deleteImage(self::get($id), $index); diff --git a/resources/views/Shop/Articles/partials/article.blade.php b/resources/views/Shop/Articles/partials/article.blade.php index 35909ec6..a57e513d 100644 --- a/resources/views/Shop/Articles/partials/article.blade.php +++ b/resources/views/Shop/Articles/partials/article.blade.php @@ -2,23 +2,29 @@
...
- {{ $product_name }} - + {{ $product_name }} +

-

+
- {{ $article['semences']['price'] ?? null }}
+ @if ($article['semences'] ?? false) + {{ $article['semences']['price'] ?? null }}
+ @else + Indisponible + @endif Semence
- @if ($article['plants'] ?? false) -
- {{ $article['plants']['price'] }}
- Plant -
- @endif +
+ @if ($article['plants'] ?? false) + {{ $article['plants']['price'] }}
+ @else + Indisponible + @endif + Plant +

diff --git a/resources/views/Shop/Articles/partials/article_rows.blade.php b/resources/views/Shop/Articles/partials/article_rows.blade.php new file mode 100644 index 00000000..defa4690 --- /dev/null +++ b/resources/views/Shop/Articles/partials/article_rows.blade.php @@ -0,0 +1,55 @@ + +
+
+
{{ $product_name }}
+
+
+
+
+
+
+
+
+ ... +
+
+ + + +
+
+
+
+ {!! $article['description'] !!} +
+
+
+
+

+

+
+ @if ($article['semences'] ?? false) + {{ $article['semences']['price'] ?? null }}
+ {{ $article['semences']['variation'] }} +
+ Quantité : +
+ @include('components.form.button', [ + 'class' => 'btn-success basket semences', + 'txt' => 'Ajouter au panier', + ]) + @endif +
+
+ @if ($article['plants'] ?? false) + {{ $article['plants']['price'] }}
+ {{ $article['plants']['variation'] }} + @endif +
+
+

+
+
+
+
+
diff --git a/resources/views/Shop/Articles/show.blade.php b/resources/views/Shop/Articles/show.blade.php new file mode 100644 index 00000000..16c7ef5b --- /dev/null +++ b/resources/views/Shop/Articles/show.blade.php @@ -0,0 +1,33 @@ +@extends('Shop.layout.layout', [ + 'title' => __('home.title'), +]) + +@section('content') +
+
+
+
+ {!! $article['image_big'] !!} +
+
+

{{ $article['name'] }}

+ {!! $article['description'] !!} +
+
+ @component('components.card', [ + 'title' => 'Semence', + 'class' => 'mb-3', + ]) + @include('components.form.button', [ + 'class' => 'btn-success basket semences', + 'txt' => 'Ajouter au panier', + ]) + @endcomponent + + @component('components.card', [ + 'title' => 'Plant', + ]) + @endcomponent +
+
+@endsection diff --git a/resources/views/Shop/home.blade.php b/resources/views/Shop/home.blade.php index 6f51486b..184a02b5 100644 --- a/resources/views/Shop/home.blade.php +++ b/resources/views/Shop/home.blade.php @@ -3,5 +3,9 @@ ]) @section('content') - @include('Shop.layout.partials.category_articles') + @if ($display_by_rows ?? true) + @include('Shop.layout.partials.category_articles_rows') + @else + @include('Shop.layout.partials.category_articles') + @endif @endsection \ No newline at end of file diff --git a/resources/views/Shop/layout/partials/category_articles_rows.blade.php b/resources/views/Shop/layout/partials/category_articles_rows.blade.php new file mode 100644 index 00000000..2f62a185 --- /dev/null +++ b/resources/views/Shop/layout/partials/category_articles_rows.blade.php @@ -0,0 +1,3 @@ +@foreach ($articles as $product_name => $article) + @include('Shop.Articles.partials.article_rows') +@endforeach diff --git a/resources/views/components/card.blade.php b/resources/views/components/card.blade.php index 37389f5e..ffee3630 100644 --- a/resources/views/components/card.blade.php +++ b/resources/views/components/card.blade.php @@ -4,7 +4,7 @@ @isset($header) {{ $header }} @else -

{{ $title }}

+

{{ $title ?? false }}

@isset($tools)
{!! $tools !!} diff --git a/resources/views/components/form/button.blade.php b/resources/views/components/form/button.blade.php index 7cfd9399..f948a12d 100644 --- a/resources/views/components/form/button.blade.php +++ b/resources/views/components/form/button.blade.php @@ -1,4 +1,6 @@ \ No newline at end of file