File: D:/HostingSpaces/Eurotools/euro-tools.nl/app/KommaApp/Shop/Checkout/CheckoutController.php
<?php
namespace App\KommaApp\Shop\Checkout;
use App\Http\Controllers\Controller;
use App\KommaApp\Forms\FormService;
use App\KommaApp\Shop\Cart\ShoppingCartController;
use App\KommaApp\Shop\Cart\ShoppingCartService;
use App\KommaApp\Shop\Catalog\Kms\CatalogServiceInterface;
use App\KommaApp\Shop\Notifications\CustomerOrderConfirmation;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
/**
* Class CheckoutController
*
* Handles the checkout process and the different views
*
* @package App\KommaApp\Shop\Checkout
*/
class CheckoutController extends Controller
{
/** @var ShoppingCartController $shoppingCart */
private $shoppingCart;
/** @var FormService $formService */
private $formService;
/** @var CheckoutService $checkoutService */
private $checkoutService;
public function __construct(ShoppingCartService $shoppingCartService, CheckoutService $checkoutService, FormService $formService)
{
parent::__construct();
$this->shoppingCart = $shoppingCartService;
$this->formService = $formService;
$this->checkoutService = $checkoutService;
}
/**
* Send a message to the Eurotools staff and customer that somebody wants to order something. And store the order.
*
* @return \Illuminate\Contracts\View\View
*/
public function checkout()
{
// $quotationRequest = $this->checkoutService->getQuotationRequestForShoppingCart($this->shoppingCart);
$remarks = Input::get('remarks', '');
$customer = \Auth::user();
$order = $this->checkoutService->createOrderFromShoppingCart($this->shoppingCart, $customer, $remarks);
Log::debug('Order with id: '.$order->id.' created');
$this->checkoutService->notifyAdminsForNewOrder($customer, $order);
Log::debug('Notifying customer: '.$customer->email.' about order '.$order->id);
$customer->notify(new CustomerOrderConfirmation($order));
Log::debug('Notified');
$page = $this->pageService->getPageByCodeName('thanks');
$page->translation = $this->decodeDynamicContent( $page->translation );
$otherLanguageRoutes = $this->languageService->getOtherLanguagesRoutes($page);
$catalogService = \App::make(CatalogServiceInterface::class);
$featuredProducts = $catalogService->getFeaturedProducts()->take(4);
return \View::make('shop.pages.thanks', [
'page' => $page,
'links' => $this->links,
'categories' => $this->categories,
'otherProducts' => $featuredProducts,
'otherLanguages' => $otherLanguageRoutes,
]);
}
}