enhance add to basket
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
88
app/Http/Controllers/Shop/Auth/LoginController.php
Normal file
88
app/Http/Controllers/Shop/Auth/LoginController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Repositories\Layout;
|
||||
use App\Repositories\Languages;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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';
|
||||
}
|
||||
}
|
||||
48
app/Http/Controllers/Shop/Auth/ResetPasswordController.php
Normal file
48
app/Http/Controllers/Shop/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
@@ -23,21 +23,21 @@ class BasketController extends Controller
|
||||
{
|
||||
$offer_id = $request->input('offer_id');
|
||||
$quantity = $request->input('quantity');
|
||||
return Offers::addBasket($offer_id, $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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -98,12 +98,12 @@ class Articles
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product;
|
||||
$specie = $variety->specie;
|
||||
$description = empty($specie->description) ? '' : $specie->description . '<br>';
|
||||
$description .= empty($variety->description) ? '' : $variety->description . '<br>';
|
||||
$description = empty($specie->description) ? '' : $specie->description . '<br><br>';
|
||||
$description .= empty($variety->description) ? '' : $variety->description . '<br><br>';
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product;
|
||||
$description = empty($specie->description) ? '' : $specie->description . '<br>';
|
||||
$description = empty($specie->description) ? '' : $specie->description . '<br><br>';
|
||||
break;
|
||||
default:
|
||||
$description = '';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -20,3 +20,5 @@
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('load.layout.modal')
|
||||
34
resources/views/Shop/Baskets/partials/modalBasket.blade.php
Normal file
34
resources/views/Shop/Baskets/partials/modalBasket.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<img src="{{ App\Repositories\Shop\Articles::getPreviewSrc($offer['article']['image'] ?? false) }}" class="card-img-top" alt="...">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="text-uppercase">
|
||||
{{ $offer['article']['article_nature']['name'] }}
|
||||
</div>
|
||||
<div>
|
||||
{{ $offer['article']['name'] }}
|
||||
</div>
|
||||
<div>
|
||||
{{ $offer['tariff']['price_lists'][0]['price_list_values'][0]['price_taxed'] }} €
|
||||
</div>
|
||||
<div>
|
||||
{{ $offer['variation']['name'] }}
|
||||
</div>
|
||||
<div>
|
||||
Quantité : {{ $basket['added']['quantity'] ?? 0 }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-7">
|
||||
<div>
|
||||
Il y a {{ $basket['quantity'] ?? 0 }} articles dans votre panier.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Total produits : </strong> {{ $basket['total'] ?? 0 }} €
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,18 +1,18 @@
|
||||
@if ($shelve['articles'])
|
||||
<div class="mb-3 bg-light">
|
||||
<div class="mb-3 bg-green-light">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h1 style="font-size: 2em;">{{ $shelve['name'] }}</h1>
|
||||
<h1 class="green" style="font-size: 2em;">{{ $shelve['name'] }}</h1>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<a href="{{ route('Shop.Categories.show', ['id' => $shelve['id']]) }}">Découvrir la sélection</a>
|
||||
<a href="{{ route('Shop.Categories.show', ['id' => $shelve['id']]) }}">Tout voir</a>
|
||||
<a class="green-dark btn" href="{{ route('Shop.Categories.show', ['id' => $shelve['id']]) }}">Découvrir la sélection</a>
|
||||
<a class="green-dark btn" href="{{ route('Shop.Categories.show', ['id' => $shelve['id']]) }}">Tout voir</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row shelve_slider_{{ $shelve['id'] }} slider">
|
||||
@foreach ($shelve['articles'] as $name => $article)
|
||||
<div class="text-center pr-2 pl-2">
|
||||
<a href="{{ route('Shop.Articles.show', ['id' => $article['id']]) }}">
|
||||
<a class="green-dark" href="{{ route('Shop.Articles.show', ['id' => $article['id']]) }}">
|
||||
<img data-lazy="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" class="d-block w-100" alt="{{ $name }}"/>
|
||||
{{ $name }}
|
||||
</a>
|
||||
|
||||
38
resources/views/Shop/layout/partials/megamenu.blade.php
Normal file
38
resources/views/Shop/layout/partials/megamenu.blade.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="container">
|
||||
<div class="row rounded m-0 drop-shadow bg-white p-2">
|
||||
<div class="col mb-4">
|
||||
@for ($i = 0; $i < round(count($category['children']) / 3); $i++)
|
||||
<strong>
|
||||
<a class="green-dark" href="{{ route('Shop.Categories.show', ['id' => $category['children'][$i]['id']]) }}">
|
||||
{{ $category['children'][$i]['name'] }}
|
||||
</a>
|
||||
</strong><br>
|
||||
@foreach ($category['children'][$i]['children'] ?? [] as $leaf)
|
||||
<a class="green-dark" href="{{ route('Shop.Categories.show', ['id' => $leaf['id']]) }}">
|
||||
{{ $leaf['name'] }}
|
||||
</a><br>
|
||||
@endforeach
|
||||
@endfor
|
||||
</div>
|
||||
<div class="col mb-4">
|
||||
@for ($i = round(count($category['children']) / 3); $i < round(2 * count($category['children']) / 3); $i++)
|
||||
<strong>{{ $category['children'][$i]['name'] }}</strong><br>
|
||||
@foreach ($category['children'][$i]['children'] ?? [] as $leaf)
|
||||
<a class="green-dark" href="{{ route('Shop.Categories.show', ['id' => $leaf['id']]) }}">
|
||||
{{ $leaf['name'] }}
|
||||
</a><br>
|
||||
@endforeach
|
||||
@endfor
|
||||
</div>
|
||||
<div class="col mb-4">
|
||||
@for ($i = round(2 * count($category['children']) / 3); $i < count($category['children']); $i++)
|
||||
<strong>{{ $category['children'][$i]['name'] }}</strong><br>
|
||||
@foreach ($category['children'][$i]['children'] ?? [] as $leaf)
|
||||
<a class="green-dark" href="{{ route('Shop.Categories.show', ['id' => $leaf['id']]) }}">
|
||||
{{ $leaf['name'] }}
|
||||
</a><br>
|
||||
@endforeach
|
||||
@endfor
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,23 +1,18 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<div class="collapse navbar-collapse" id="navbarContent">
|
||||
<ul class="navbar-nav mx-auto">
|
||||
@foreach ($categories as $category)
|
||||
@if (isset($category['children']))
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ $category['name'] }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
@include('Shop.layout.partials.submenu', ['categories' => $category['children']])
|
||||
</ul>
|
||||
</li>
|
||||
@else
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('Shop.Categories.show', ['id' => $category['id']]) }}">{{ $category['name'] }}</a>
|
||||
</li>
|
||||
@endif
|
||||
<li class="nav-item dropdown megamenu">
|
||||
<a id="megamenu_{{ $category['id'] }}" href="{{ route('Shop.Categories.show', ['id' => $category['id']]) }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle font-weight-bold text-uppercase">
|
||||
{{ $category['name'] }}
|
||||
</a>
|
||||
@if (isset($category['children']))
|
||||
<div aria-labelledby="megamenu_{{ $category['id'] }}" class="dropdown-menu border-0 p-0 m-0">
|
||||
@include('Shop.layout.partials.megamenu')
|
||||
</div>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
|
||||
<span style="font-family: Arial Narrow; font-size: 1.1em; font-weight: 900;">
|
||||
|
||||
28
resources/views/Shop/layout/partials/sections_old.blade.php
Normal file
28
resources/views/Shop/layout/partials/sections_old.blade.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
@foreach ($categories as $category)
|
||||
@if (isset($category['children']))
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ $category['name'] }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
@include('Shop.layout.partials.submenu', ['categories' => $category['children']])
|
||||
</ul>
|
||||
</li>
|
||||
@else
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('Shop.Categories.show', ['id' => $category['id']]) }}">{{ $category['name'] }}</a>
|
||||
</li>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
|
||||
<span style="font-family: Arial Narrow; font-size: 1.1em; font-weight: 900;">
|
||||
Variétés Paysannes de la Semence à l'Assiette
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
@@ -3,7 +3,7 @@
|
||||
@push('js')
|
||||
|
||||
<script>
|
||||
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm) {
|
||||
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm, buttons) {
|
||||
var status = 0;
|
||||
var dialog = bootbox.dialog({
|
||||
title: title,
|
||||
@@ -13,7 +13,7 @@
|
||||
onHide: function(e) {
|
||||
console.log(status);
|
||||
},
|
||||
buttons: buildModalButtons(form_id, no_confirm)
|
||||
buttons: buildModalButtons(form_id, no_confirm, buttons)
|
||||
});
|
||||
|
||||
dialog.init(function() {
|
||||
@@ -53,7 +53,7 @@
|
||||
window.open(url,title,"menubar=no, status=no, scrollbars=no, menubar=no, width=" + width + ", height=400");
|
||||
}
|
||||
|
||||
function buildModalButtons(form_id, no_confirm) {
|
||||
function buildModalButtons(form_id, no_confirm, buttons) {
|
||||
if (!no_confirm) {
|
||||
var buttons = {
|
||||
cancel: {
|
||||
@@ -68,8 +68,6 @@
|
||||
}
|
||||
},
|
||||
};
|
||||
} else {
|
||||
buttons = '';
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Route::prefix('Basket')->name('Basket.')->group(function () {
|
||||
Route::post('getPrice', 'BasketController@getPrice')->name('getPrice');
|
||||
Route::post('addBasket', 'BasketController@addBasket')->name('addBasket');
|
||||
Route::get('modalBasket/{offer_id?}/{quantity?}', 'BasketController@modalBasket')->name('modalBasket');
|
||||
Route::get('getBasket', 'BasketController@getBasket')->name('getBasket');
|
||||
Route::get('countBasket', 'BasketController@countBasket')->name('countBasket');
|
||||
Route::get('clearBasket', 'BasketController@clearBasket')->name('clearBasket');
|
||||
|
||||
Reference in New Issue
Block a user