diff --git a/app/Http/Controllers/Shop/ArticleController.php b/app/Http/Controllers/Shop/ArticleController.php index efa55f72..b7ee3e8b 100644 --- a/app/Http/Controllers/Shop/ArticleController.php +++ b/app/Http/Controllers/Shop/ArticleController.php @@ -14,8 +14,6 @@ class ArticleController extends Controller { $data = self::init(); $data['article'] = Articles::getArticleToSell($id); - // dump($data); - // exit; return view('Shop.Articles.show', $data); } } diff --git a/app/Http/Controllers/Shop/Auth/LoginController.php b/app/Http/Controllers/Shop/Auth/LoginController.php new file mode 100644 index 00000000..367d103d --- /dev/null +++ b/app/Http/Controllers/Shop/Auth/LoginController.php @@ -0,0 +1,88 @@ +middleware('customer')->except('logout'); + } + + public function showLoginForm() + { + $data['url'] = route('Shop.Auth.login.post'); + return view('Shop.Auth.login', $data); + } + + protected function guard() + { + return Auth::guard('customer'); + } + + public function login(Request $request) + { + $this->validate($request, [ + 'username' => 'required|email', + 'password' => 'required|min:6' + ]); + + if (Auth::guard('customer')->attempt(['username' => $request->username, 'password' => $request->password], $request->get('remember'))) { + return redirect()->intended(route('Conferencing.event')); + } + return back()->withInput($request->only('username', 'remember')); + } + + public function logout(Request $request) + { + + // Get the session key for this user + $sessionKey = $this->guard()->getName(); + + $this->guard()->logout(); + + // Delete single session key (just for this user) + $request->session()->forget($sessionKey); + + return redirect()->route('home'); + } + + public function username() + { + return 'username'; + } +} diff --git a/app/Http/Controllers/Shop/Auth/ResetPasswordController.php b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php new file mode 100644 index 00000000..533a51ce --- /dev/null +++ b/app/Http/Controllers/Shop/Auth/ResetPasswordController.php @@ -0,0 +1,48 @@ +middleware('guest'); + } + + public function showResetForm(Request $request, $token = null) + { + $data = $this->initHeader(); + $data['token'] = $token; + $data['email'] = $request->email; + return view('Auth.passwords.reset', $data); + } +} diff --git a/app/Http/Controllers/Shop/BasketController.php b/app/Http/Controllers/Shop/BasketController.php index 29b65297..e4a17822 100644 --- a/app/Http/Controllers/Shop/BasketController.php +++ b/app/Http/Controllers/Shop/BasketController.php @@ -23,21 +23,21 @@ class BasketController extends Controller { $offer_id = $request->input('offer_id'); $quantity = $request->input('quantity'); - - if (ShopCart::has($offer_id)) { - $ret = ShopCart::remove($offer_id); - } - $data = $quantity ? Offers::getBasketData($offer_id, $quantity) : false; - $ret = $data ? ShopCart::add($data) : false; - return true; + return Offers::addBasket($offer_id, $quantity); } - + + + public function modalBasket($offer_id, $quantity) + { + $data['offer'] = Offers::getFull($offer_id)->toArray(); + $data['basket'] = Offers::addBasket($offer_id, $quantity); + return view('Shop.Baskets.partials.modalBasket', $data); + } + public function basket() { $data = self::init(); $data['basket'] = Offers::getBasket(); - //dump($data['basket']); - // exit; return view('Shop.Baskets.basket', $data); } diff --git a/app/Repositories/Core/User/ShopCart.php b/app/Repositories/Core/User/ShopCart.php index 1b3967a9..417b7a23 100644 --- a/app/Repositories/Core/User/ShopCart.php +++ b/app/Repositories/Core/User/ShopCart.php @@ -8,9 +8,15 @@ use \Cart; class ShopCart { - public static function add($data) + public static function add($item) { - return self::get()->add($data); + $ret = self::get()->add($item); + return [ + 'count' => self::count(), + 'quantity' => self::getTotalQuantity(), + 'total' => self::getTotal(), + 'added' => $item, + ]; } public static function remove($id) @@ -39,6 +45,16 @@ class ShopCart return self::getContent()->count(); } + public static function getTotalQuantity() + { + return self::get()->getTotalQuantity(); + } + + public static function getTotal() + { + return self::get()->getTotal(); + } + public static function getContent() { return self::get()->getContent(); diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index b216d4e0..bfc0aeeb 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -98,12 +98,12 @@ class Articles case 'App\Models\Botanic\Variety': $variety = $article->product; $specie = $variety->specie; - $description = empty($specie->description) ? '' : $specie->description . '
'; - $description .= empty($variety->description) ? '' : $variety->description . '
'; + $description = empty($specie->description) ? '' : $specie->description . '

'; + $description .= empty($variety->description) ? '' : $variety->description . '

'; break; case 'App\Models\Botanic\Specie': $specie = $article->product; - $description = empty($specie->description) ? '' : $specie->description . '
'; + $description = empty($specie->description) ? '' : $specie->description . '

'; break; default: $description = ''; diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 20b0fcd0..5fb6db2d 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -7,6 +7,32 @@ use App\Repositories\Core\User\ShopCart; class Offers { + public static function addBasket($offer_id, $quantity = 1) + { + if (ShopCart::has($offer_id)) { + $ret = ShopCart::remove($offer_id); + } + $data = $quantity ? Offers::getBasketData($offer_id, $quantity) : false; + return $data ? ShopCart::add($data) : false; + } + + public static function getFull($id, $sale_channel_id = false) + { + $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); + return Offer::with([ + 'article.article_nature', + 'article.product', + 'article.image', + 'tariff' => function ($query) use ($sale_channel_id) { + $query->bySaleChannel($sale_channel_id); + }, + 'tariff.price_lists' => function ($query) use ($sale_channel_id) { + $query->BySaleChannel($sale_channel_id); + }, + 'tariff.price_lists.price_list_values', + 'variation', + ])->find($id); + } public static function getPrice($id, $quantity = 1, $sale_channel_id = false) { @@ -153,5 +179,4 @@ class Offers { return self::update(['status_id' => $status_id], $id); } - } diff --git a/build/css/site.css b/build/css/site.css index 14f2466e..a6045816 100644 --- a/build/css/site.css +++ b/build/css/site.css @@ -23,6 +23,13 @@ body { color: #335012; } +a.green-dark:hover { + color: #335012; + font-weight: 900; + text-decoration: none; + text-shadow: 4px black; +} + .green-light { color: #F1F7EE; } @@ -43,6 +50,16 @@ body { color: #F5F5F5; } +.megamenu { + position: static +} + +.megamenu .dropdown-menu { + background: none; + border: none; + width: 100% +} + @font-face { font-family: 'noto_sanscondensed'; src: url('/fonts/notosans-condensed/notosans-condensed-webfont.eot'); diff --git a/resources/views/Shop/Articles/partials/ArticleAddBasket.blade.php b/resources/views/Shop/Articles/partials/ArticleAddBasket.blade.php index d7fc62b1..0deab8ea 100644 --- a/resources/views/Shop/Articles/partials/ArticleAddBasket.blade.php +++ b/resources/views/Shop/Articles/partials/ArticleAddBasket.blade.php @@ -32,14 +32,32 @@ 'offer_id': offer_id, 'quantity': quantity, }; - $.post('{{ route("Shop.Basket.addBasket") }}', data, function() { - console.log('ici'); - }); - console.log(type); - console.log(offer_id); - console.log(quantity); - console.log(data); - }); + + var buttons = { + cancel: { + label: '{{ __('Continuer mes achats') }}', + className: 'btn-secondary' + }, + confirm: { + label: '{{ __('Commander') }}', + className: 'btn-success', + callback: function() { + submitModal(form_id); + } + }, + }; + + openModal( + 'Ajout dans le panier', + 'basket-form', + "{{ route('Shop.Basket.modalBasket') }}/" + offer_id + '/' + quantity, + "{{ route('Shop.Basket.addBasket') }}", + false, + false, + true, + buttons + ); + }); function setPrice(model) { var offer_id = $('#' + model + '-offer_id').find('option:selected').val(); diff --git a/resources/views/Shop/Articles/show.blade.php b/resources/views/Shop/Articles/show.blade.php index 96a6c05f..e2621a99 100644 --- a/resources/views/Shop/Articles/show.blade.php +++ b/resources/views/Shop/Articles/show.blade.php @@ -20,3 +20,5 @@ @endsection + +@include('load.layout.modal') \ No newline at end of file diff --git a/resources/views/Shop/Baskets/partials/modalBasket.blade.php b/resources/views/Shop/Baskets/partials/modalBasket.blade.php new file mode 100644 index 00000000..aab2085c --- /dev/null +++ b/resources/views/Shop/Baskets/partials/modalBasket.blade.php @@ -0,0 +1,34 @@ +
+
+
+
+ ... +
+
+
+ {{ $offer['article']['article_nature']['name'] }} +
+
+ {{ $offer['article']['name'] }} +
+
+ {{ $offer['tariff']['price_lists'][0]['price_list_values'][0]['price_taxed'] }} € +
+
+ {{ $offer['variation']['name'] }} +
+
+ Quantité : {{ $basket['added']['quantity'] ?? 0 }} +
+
+
+
+
+
+ Il y a {{ $basket['quantity'] ?? 0 }} articles dans votre panier. +
+
+ Total produits : {{ $basket['total'] ?? 0 }} € +
+
+
diff --git a/resources/views/Shop/Homepage/partials/sliderByShelve.blade.php b/resources/views/Shop/Homepage/partials/sliderByShelve.blade.php index af9bd146..53c96836 100644 --- a/resources/views/Shop/Homepage/partials/sliderByShelve.blade.php +++ b/resources/views/Shop/Homepage/partials/sliderByShelve.blade.php @@ -1,18 +1,18 @@ @if ($shelve['articles']) -
+
-

{{ $shelve['name'] }}

+

{{ $shelve['name'] }}

@foreach ($shelve['articles'] as $name => $article)
- + {{ $name }} {{ $name }} diff --git a/resources/views/Shop/layout/partials/megamenu.blade.php b/resources/views/Shop/layout/partials/megamenu.blade.php new file mode 100644 index 00000000..9ca384cb --- /dev/null +++ b/resources/views/Shop/layout/partials/megamenu.blade.php @@ -0,0 +1,38 @@ +
+
+
+ @for ($i = 0; $i < round(count($category['children']) / 3); $i++) + + + {{ $category['children'][$i]['name'] }} + +
+ @foreach ($category['children'][$i]['children'] ?? [] as $leaf) + + {{ $leaf['name'] }} +
+ @endforeach + @endfor +
+
+ @for ($i = round(count($category['children']) / 3); $i < round(2 * count($category['children']) / 3); $i++) + {{ $category['children'][$i]['name'] }}
+ @foreach ($category['children'][$i]['children'] ?? [] as $leaf) + + {{ $leaf['name'] }} +
+ @endforeach + @endfor +
+
+ @for ($i = round(2 * count($category['children']) / 3); $i < count($category['children']); $i++) + {{ $category['children'][$i]['name'] }}
+ @foreach ($category['children'][$i]['children'] ?? [] as $leaf) + + {{ $leaf['name'] }} +
+ @endforeach + @endfor +
+
+
\ No newline at end of file diff --git a/resources/views/Shop/layout/partials/sections.blade.php b/resources/views/Shop/layout/partials/sections.blade.php index 663c128f..e06281f5 100644 --- a/resources/views/Shop/layout/partials/sections.blade.php +++ b/resources/views/Shop/layout/partials/sections.blade.php @@ -1,23 +1,18 @@