affichage "mes commandes"
This commit is contained in:
parent
bf060e2ad4
commit
23cad1bf96
13 changed files with 238 additions and 47 deletions
|
|
@ -9,11 +9,17 @@ use Gloudemans\Shoppingcart\Facades\Cart;
|
|||
|
||||
class BasketController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('basket');
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
// public function index(Request $request)
|
||||
// {
|
||||
// return view('basket');
|
||||
// }
|
||||
|
||||
/**
|
||||
* ajout de produit au panier
|
||||
*/
|
||||
public function addToCart(Request $request)
|
||||
{
|
||||
$product = Product::find($request->id);
|
||||
|
|
@ -22,6 +28,9 @@ class BasketController extends Controller
|
|||
return $this->getCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* suppression de produit du panier
|
||||
*/
|
||||
public function removeFromCart(Request $request)
|
||||
{
|
||||
$rowId = $request->rowId;
|
||||
|
|
@ -29,11 +38,17 @@ class BasketController extends Controller
|
|||
return $this->getCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* vidage de panier
|
||||
*/
|
||||
public function emptyCart() {
|
||||
Cart::destroy();
|
||||
return $this->getCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* récupération du panier
|
||||
*/
|
||||
public function getCart() {
|
||||
|
||||
$dbpanier = new Collection();
|
||||
|
|
|
|||
|
|
@ -22,11 +22,18 @@ use Illuminate\Support\Facades\Session;
|
|||
|
||||
class OrdersController extends Controller
|
||||
{
|
||||
/**
|
||||
* index of orders (Bo)
|
||||
*/
|
||||
public function index() {
|
||||
$orders = Order::orderBy('date', 'DESC')->get();
|
||||
return view('bo.orders', compact('orders'));
|
||||
return view('bo.orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
/**
|
||||
* action de changement de statut vers l'avant
|
||||
* @todo : envoyer les mails transactionnels
|
||||
*/
|
||||
public function changeStatus($reference) {
|
||||
$order = Order::where('reference', $reference)->first();
|
||||
$order->status_id = $order->status_id + 1;
|
||||
|
|
@ -36,6 +43,9 @@ class OrdersController extends Controller
|
|||
return back()->with('success', "Changement de status enregistré pour la commande " . $order->reference . ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* mise au statut annulé d'une commande
|
||||
*/
|
||||
public function cancelOrder($reference) {
|
||||
$order = Order::where('reference', $reference)->first();
|
||||
$order->status_id = 7;
|
||||
|
|
@ -45,6 +55,11 @@ class OrdersController extends Controller
|
|||
return back()->with('success', "La commande " . $order->reference . " à été annulée.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* ajout de produits à la commande
|
||||
* @todo : supprimer cette méthode qui repose sur un modèle de donnée osolète
|
||||
*/
|
||||
public function addProduct($orderReference, $productId, $quantity) {
|
||||
$product = Product::findOrFail($productId);
|
||||
$order = Order::where('reference', $orderReference)->first();
|
||||
|
|
@ -60,7 +75,11 @@ class OrdersController extends Controller
|
|||
return redirect()->route('bo.orders')->with('success', "Le produit à été ajouté.");
|
||||
}
|
||||
|
||||
//front sales tunnel step2 recap
|
||||
/**
|
||||
* front
|
||||
* récap panier du tunnel de commande
|
||||
* @todo : déplacer vers le controller idoine
|
||||
*/
|
||||
public function recapOrder()
|
||||
{
|
||||
$activestep = 2;
|
||||
|
|
@ -80,8 +99,8 @@ class OrdersController extends Controller
|
|||
return view('sales.recap', compact('activestep', 'cart', 'cartInfos'));
|
||||
}
|
||||
|
||||
//save order and go to step 3
|
||||
/**
|
||||
* front
|
||||
* Storing order from sales tunnel
|
||||
*/
|
||||
public function store()
|
||||
|
|
@ -130,7 +149,9 @@ class OrdersController extends Controller
|
|||
return redirect()->route('sales.pick-slot', ['reference' => $order->reference]);
|
||||
}
|
||||
|
||||
//pick your time slot
|
||||
/**
|
||||
* front tunnel de commande étape 3 : choix de créneau
|
||||
*/
|
||||
public function timeSlotPick($reference)
|
||||
{
|
||||
$activestep = 3;
|
||||
|
|
@ -198,7 +219,11 @@ class OrdersController extends Controller
|
|||
return view('sales.pick-slot', compact('activestep', 'availCreneaux', 'order'));
|
||||
}
|
||||
|
||||
//save timeslot and validate order
|
||||
/**
|
||||
* front
|
||||
* enregistrement du créneau de collect
|
||||
* et validation de la commande
|
||||
*/
|
||||
public function setTimeSlot(Request $request)
|
||||
{
|
||||
$time_slot = Carbon::createFromFormat('d/m/Y-H:i', $request->selectedcreneau);
|
||||
|
|
@ -228,7 +253,10 @@ class OrdersController extends Controller
|
|||
return redirect()->route('sales.confirm', ['reference' => $order->reference]);
|
||||
}
|
||||
|
||||
//show confirmation
|
||||
/**
|
||||
* front
|
||||
* page de confirmation de commande
|
||||
*/
|
||||
public function confirmOrder($reference)
|
||||
{
|
||||
$activestep = 4;
|
||||
|
|
@ -239,14 +267,21 @@ class OrdersController extends Controller
|
|||
return view('sales.confirm', compact('activestep', 'order'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bo
|
||||
* ajx : affichage d'infos sur un client
|
||||
* @todo : déplacer dans le controller idoine
|
||||
*/
|
||||
public function getCustomerInfo($id) {
|
||||
$cust = Customers::findOrFail($id);
|
||||
return view('bo.customer.info-popup', compact('cust'));
|
||||
}
|
||||
|
||||
/**
|
||||
* bo : page détatil commande
|
||||
*/
|
||||
public function orderDetail($reference) {
|
||||
$order = Order::where('reference', '=', $reference)->firstOrFail();
|
||||
return view('bo.order.detail', compact('order'));
|
||||
return view('bo.orders.detail', compact('order'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,18 @@ use Illuminate\Support\Str;
|
|||
|
||||
class ProductsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Bo index page for products
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$products = Product::paginate(10);
|
||||
return view('bo.products.index', compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* create à product
|
||||
*/
|
||||
public function create(Request $request, $product_type)
|
||||
{
|
||||
if (!array_key_exists($product_type, config('theme.enum_product_types'))) {
|
||||
|
|
@ -31,6 +37,10 @@ class ProductsController extends Controller
|
|||
return view('bo.products.create', compact('product_type', 'product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* store a new product
|
||||
* @todo : manage tags and associated products
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//products fields
|
||||
|
|
@ -125,6 +135,9 @@ class ProductsController extends Controller
|
|||
return redirect()->route('bo.products.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* edit an existing product
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
|
@ -151,6 +164,9 @@ class ProductsController extends Controller
|
|||
return view('bo.products.edit', compact('product', 'ranges','existingTags', 'selectedtags', 'existingProds', 'selectedProds'));
|
||||
}
|
||||
|
||||
/**
|
||||
* update an existing product
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
|
|
@ -280,6 +296,10 @@ class ProductsController extends Controller
|
|||
return redirect()->route('bo.products.edit', $product->id)->with('success', 'Modifications enregistrés !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to store a new tag if necessary
|
||||
* Otherwise retreive an existing tag to associate its id
|
||||
*/
|
||||
public function storeTag($oTag)
|
||||
{
|
||||
$slug = Str::slug($oTag->label);
|
||||
|
|
@ -294,6 +314,10 @@ class ProductsController extends Controller
|
|||
return $tag->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy a product (soft delete)
|
||||
* @todo : manage liaisons
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
|
@ -311,6 +335,10 @@ class ProductsController extends Controller
|
|||
return redirect()->route('bo.products.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* foodProduct
|
||||
*/
|
||||
public function saveFoodProduct(Request $request, $product_id)
|
||||
{
|
||||
$foodProduct = FoodProduct::firstOrNew([
|
||||
|
|
@ -361,6 +389,10 @@ class ProductsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to create additionnal product info
|
||||
* foodProduct
|
||||
*/
|
||||
public function storeFoodProduct(Request $request, $product_id)
|
||||
{
|
||||
$foodProduct = new FoodProduct();
|
||||
|
|
@ -409,6 +441,9 @@ class ProductsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* product detail intended for Bo
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
//not in use
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Http\Requests\UpdateInfosRequest;
|
|||
use App\Mail\PasswordResetMail;
|
||||
use App\Mail\RegisterConfirmMail;
|
||||
use App\Models\Customers;
|
||||
use App\Models\Order;
|
||||
use App\Models\PasswordReset;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -30,6 +31,7 @@ class CustomerController extends Controller
|
|||
|
||||
/**
|
||||
* Enregistre le customer dans la base de données
|
||||
* et CRM
|
||||
*/
|
||||
public function register(CustomerRegisterRequest $request)
|
||||
{
|
||||
|
|
@ -162,6 +164,9 @@ class CustomerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deconnexion customer
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
if (Auth::guard('customer')->check()) {
|
||||
|
|
@ -170,11 +175,17 @@ class CustomerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* page d'accès à la procédure mdp oublié
|
||||
*/
|
||||
public function forgotPasswordForm(Request $request)
|
||||
{
|
||||
return view('auth.passwords.forgot');
|
||||
}
|
||||
|
||||
/**
|
||||
* initialisation de la procédure de mdp oublié
|
||||
*/
|
||||
public function passwordReset(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -223,6 +234,9 @@ class CustomerController extends Controller
|
|||
return view('auth.passwords.reset', compact('customer'))->with('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* changement de mot de passe (depuis la procédure de mdp oublié)
|
||||
*/
|
||||
public function changePassword(Request $request, $token)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -257,6 +271,9 @@ class CustomerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* profil client (mon compte)
|
||||
*/
|
||||
public function dashboard(Request $request)
|
||||
{
|
||||
|
||||
|
|
@ -311,6 +328,9 @@ class CustomerController extends Controller
|
|||
->with('success', __("Vos informations ont bien été enregistrées."));
|
||||
}
|
||||
|
||||
/**
|
||||
* changement de mot de passe depuis le profil
|
||||
*/
|
||||
public function changePasswordWhenAuthenticated(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -327,29 +347,20 @@ class CustomerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// public function changeOptin($token)
|
||||
// {
|
||||
// // TODO : Route et test de la méthode avec nouveau client CRM pour l'opt in
|
||||
// die("Attente");
|
||||
// $crmId = Customers::where('hashcode', $token)->first()->crm_id;
|
||||
/**
|
||||
* affichage des commandes du customer connecté
|
||||
*/
|
||||
public function myOrders(Request $request) {
|
||||
$orders = Order::where('customer_id', Auth::guard('customer')->user()->id)->orderBy('date', 'DESC')->get();
|
||||
return view('customer.my-orders', compact('orders'));
|
||||
}
|
||||
|
||||
// /** @var \App\Lib\LDCCRM\ApiV1 */
|
||||
// $crm = app('crmApi');
|
||||
// $result = $crm->toggleOptInCustomer($crmId);
|
||||
// if ($result->status === "OK") {
|
||||
// dd("OK");
|
||||
// return back()->with('success', 'Modification enregistrée !');
|
||||
// } else {
|
||||
// switch ($result->code) {
|
||||
// case 113 || 114:
|
||||
// dd("KO 113 ou 114");
|
||||
// return back()->withErrors("Mise à jour impossible, compte inexistant.");
|
||||
// default:
|
||||
// dd("KO default");
|
||||
// return back()->withErrors("Une erreur est survenue, merci de réessayer ultérieurement.");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
public function orderDetail($reference) {
|
||||
$order = Order::where('reference', '=', $reference)
|
||||
->where('customer_id', Auth::guard('customer')->user()->id)
|
||||
->firstOrFail();
|
||||
return view('customer.order-detail', compact('order'));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,14 +8,6 @@ use Illuminate\Http\Request;
|
|||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$content = Content::where('key', 'accueil')->first();
|
||||
return view('home', compact('content'));
|
||||
}
|
||||
|
||||
public function contact(Request $request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ use Illuminate\Support\Str;
|
|||
|
||||
class ProductsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* page des gammes
|
||||
*/
|
||||
public function ranges(Request $request)
|
||||
{
|
||||
//now in AppServiceProvider
|
||||
|
|
@ -18,6 +22,9 @@ class ProductsController extends Controller
|
|||
return view('ranges');
|
||||
}
|
||||
|
||||
/**
|
||||
* page une gamme
|
||||
*/
|
||||
public function range(Request $request, $range_slug)
|
||||
{
|
||||
$range = Range::where('slug', $range_slug)->first();
|
||||
|
|
@ -27,6 +34,9 @@ class ProductsController extends Controller
|
|||
return view('range', compact('range','products','offres'));
|
||||
}
|
||||
|
||||
/**
|
||||
* page produit
|
||||
*/
|
||||
public function product(Request $request, $product_slug) {
|
||||
$product = Product::where('slug', $product_slug)->first();
|
||||
$product->additionnalProductInfo = $product->additionnalProductInfo($product->product_type);
|
||||
|
|
@ -42,6 +52,10 @@ class ProductsController extends Controller
|
|||
return view ('product', compact('product', 'associated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* tous les produits
|
||||
* recherche par nom de produit
|
||||
*/
|
||||
public function allProducts(Request $request)
|
||||
{
|
||||
|
||||
|
|
@ -60,6 +74,9 @@ class ProductsController extends Controller
|
|||
return view('search', compact('products', 'search_title', 'filter'));
|
||||
}
|
||||
|
||||
/**
|
||||
* produits filtrés par tag (1 tag)
|
||||
*/
|
||||
public function tagFiltered(Request $request, $tag_slug)
|
||||
{
|
||||
$products = Product::where('status', 1)
|
||||
|
|
|
|||
|
|
@ -41,12 +41,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
{{-- Popup --}}
|
||||
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
|
@ -7,6 +7,14 @@
|
|||
<h1 class="title">{{ __('Mon Compte') }}</h1>
|
||||
|
||||
<div class="profile-actions flex">
|
||||
<div class="my-orders flex">
|
||||
<a href="{{ route('account.my-orders') }}">
|
||||
<span class="header-actions__item-icon icon">icone commandes</span>
|
||||
</a>
|
||||
<a href="{{ route('account.my-orders') }}">
|
||||
<span class="header-actions__item-title">Mes commandes</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="disconnect flex">
|
||||
{{-- route de déconnexion --}}
|
||||
<a href="{{ route('auth.deconnexion') }}">
|
||||
|
|
|
|||
35
resources/views/front/canard/customer/my-orders.blade.php
Normal file
35
resources/views/front/canard/customer/my-orders.blade.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('title', __('Mes Commandes'))
|
||||
|
||||
@section('content')
|
||||
<div class="wrapper">
|
||||
<h1 class="title">Mes Commandes</h1>
|
||||
<div class="section section_white">
|
||||
<div class="wrapper-inner">
|
||||
<div class="order_recap">
|
||||
<!--start header-->
|
||||
<div class="order_recap__header order_recap_action"></div>
|
||||
<div class="order_recap__header order_recap_designation">Référence</div>
|
||||
<div class="order_recap__header order_recap_quantite">Date</div>
|
||||
<div class="order_recap__header order_recap_unitprice">Total en €</div>
|
||||
<div class="order_recap__header order_recap_totalprice">Statut</div>
|
||||
<!--end header-->
|
||||
@foreach ($orders as $order)
|
||||
<div class="order_recap__row order_recap_action">
|
||||
{{--<a href="{{route('account.order-detail', $order->reference)}}" class="btn btn-sm btn-primary">Détails</a>--}}
|
||||
</div>
|
||||
<div class="order_recap__row order_recap_designation">
|
||||
<a href="{{route('account.order-detail', $order->reference)}}" class="btn btn-sm btn-primary">{{$order->reference}}</a>
|
||||
</div>
|
||||
<div class="order_recap__row order_recap_quantite">
|
||||
{{\Carbon\Carbon::parse($order->date)->format('d/m/Y')}}
|
||||
</div>
|
||||
<div class="order_recap__row order_recap_unitprice">@fmt_currency($order->total)</div>
|
||||
<div class="order_recap__row order_recap_totalprice">{{$order->status->label}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
38
resources/views/front/canard/customer/order-detail.blade.php
Normal file
38
resources/views/front/canard/customer/order-detail.blade.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@extends('layouts.layout',['brParam' => $order->reference])
|
||||
|
||||
@section('title', __('Détail Commande'))
|
||||
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="wrapper">
|
||||
<h1 class="title">Détail de votre commande du {{\Carbon\Carbon::parse($order->date)->format('d/m/Y')}}</h1>
|
||||
<div class="section">
|
||||
<div class="wrapper-inner">
|
||||
<div class="recap_order">
|
||||
<div class="message center">Etat de votre commande : {{$order->status->label}}</div>
|
||||
<div class="order__identification">Rappel de votre commande ref: {{ $order->reference }}</div>
|
||||
@foreach ($order->lines as $line)
|
||||
<div class="order__line">
|
||||
<div class="qtt">{{ $line->quantity }} x</div>
|
||||
<div class="designation">{{ $line->product->name }}</div>
|
||||
<div class="price">{{ $line->formattedTotalTtc }}</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<div class="order_total">
|
||||
<div>Total</div>
|
||||
<div>{{ $order->formattedTotalTtc }}</div>
|
||||
</div>
|
||||
<div class="message">
|
||||
A retirer le <b>{{$order->timeslot->day}} à {{$order->timeslot->time}}</b>, à l’adresse suivante :</br>
|
||||
<b>Mon point de retrait express, 15 avenue du Boulevard, 72450 Nom-de-Ville</b>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{--<a class="btn btn_blue" href="#">Voir l'itinéraire</a>--}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -106,6 +106,14 @@ Breadcrumbs::for('account.dashboard', function ($trail) {
|
|||
$trail->parent('home');
|
||||
$trail->push(__('Mon Compte'), route('account.dashboard'));
|
||||
});
|
||||
Breadcrumbs::for('account.my-orders', function ($trail) {
|
||||
$trail->parent('home');
|
||||
$trail->push(__('Mes Commandes'), route('account.my-orders'));
|
||||
});
|
||||
Breadcrumbs::for('account.order-detail', function ($trail, $reference) {
|
||||
$trail->parent('account.my-orders');
|
||||
$trail->push(__('Détail Commandes'), route('account.order-detail', ['reference', $reference]));
|
||||
});
|
||||
|
||||
// Second level
|
||||
Breadcrumbs::for('range', function ($trail, $gamme) {
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ Route::name('account.')
|
|||
Route::get('/profil', [CustomerController::class, 'dashboard'])->name('dashboard');
|
||||
Route::post('/profil', [CustomerController::class, 'updateInfos'])->name('update-infos');
|
||||
Route::post('/profil/change-mdp', [CustomerController::class, 'changePasswordWhenAuthenticated'])->name('change-password');
|
||||
Route::get('/commandes', [CustomerController::class, 'myOrders'])->name('my-orders');
|
||||
Route::get('/commandes/{reference}', [CustomerController::class, 'orderDetail'])->name('order-detail');
|
||||
});
|
||||
|
||||
//tunnel de commande
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue