File: D:/HostingSpaces/SBogers10/umans.komma.pro/app/Komma/Contact/ContactController.php
<?php
/**
* Short description for the file.
*
* @author Komma <support@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Contact;
use Ixudra\Curl\Facades\Curl;
use Komma\Blocks\BlockService;
use Komma\LanguageService;
use Komma\Mailers\MailService;
use Komma\Pages\PageService;
class ContactController extends \BaseController
{
protected $contactService;
protected $mailService;
protected $pageService;
protected $blockService;
public $languageService;
/**
* ContactController constructor.
* @param ContactService $contactService
* @param MailService $mailService
* @param PageService $pageService
*/
public function __construct(ContactService $contactService, BlockService $blockService, MailService $mailService, PageService $pageService, LanguageService $languageService)
{
parent::__construct();
$this->pageService = $pageService;
$this->mailService = $mailService;
$this->contactService = $contactService;
$this->blockService = $blockService;
$this->languageService = $languageService;
}
/**
* This method returns the contact form view
*
* @param bool $sent
* @return mixed
*/
public function contactForm($page = null, $sent = false)
{
if( ! isset($page)){
$this->languageService->checkRouteWithSetLanguage();
$page = $this->pageService->getPageByCodeName('contact');
}
$links = $this->pageService->getAllRoutes();
//Return the view
return \View::make('layouts.pages.contact')
->with('page', $page)
->with('links', $links)
->with('sent', $sent);
}
public function contactSuccess()
{
return $this->contactForm(null, true);
}
/**
* This method processes the contact form
*
* @return null
*/
public function contactFormProcess()
{
//Validate the input
$validation = $this->contactService->validateContactForm(\Input::all());
//If validation is not null and the request is via ajax, return the validation messages
if($validation !== null && \Request::ajax()) return $validation;
\Log::info($validation);
//If The validation is not null, redirect back to the form with the errors.
if($validation !== null) return \Redirect::back()->withErrors($validation)->withInput();
$input = \Input::all();
$input['site'] = \Request::root();
$this->mailService->saveMailToDatabase($input);
$this->mailService->sendContactForm($input);
//If the request ia via ajax, return the string true
//For the normal request show the contactForm page. with the send variable set to true
return 'true';
}
public function offerForm($page = null, $sent = false){
if( ! isset($page)){
$this->languageService->checkRouteWithSetLanguage();
$page = $this->pageService->getPageByCodeName('offer');
}
$links = $this->pageService->getAllRoutes();
//Return the view
return \View::make('layouts.pages.offer')
->with('page', $page)
->with('links', $links)
->with('sent', $sent);
}
/**
* This method processes the contact form
*
* @return null
*/
public function offerFormProcess()
{
//Validate the input
$validation = $this->contactService->validateFullOfferForm(\Input::all());
\Log::info($validation);
//If The validation is not null, redirect back to the form with the errors.
if($validation !== null) return \Redirect::back()->withErrors($validation)->withInput();
$input = \Input::all();
$input['site'] = \Request::root();
$this->mailService->saveMailToDatabase($input);
$this->mailService->sendFullOfferForm($input);
//If the request ia via ajax, return the string true
//For the normal request show the contactForm page. with the send variable set to true
// dd('hier');
return \Redirect::to('offerte-aanvragen/bedankt');
}
public function offerFormSuccess(){
return $this->offerForm(null, true);
}
/**
* This method processes the contact form
*
* @return null
*/
public function offerProcess()
{
//Validate the input
$validation = $this->contactService->validateOfferForm(\Input::all());
//If validation is not null and the request is via ajax, return the validation messages
if($validation !== null && \Request::ajax()) return $validation;
\Log::info($validation);
//If The validation is not null, redirect back to the form with the errors.
if($validation !== null) return \Redirect::back()->withErrors($validation)->withInput();
$input = \Input::all();
$input['site'] = \Request::root();
$this->mailService->saveMailToDatabase($input, 'quick-form');
$this->mailService->sendOfferForm($input);
//If the request ia via ajax, return the string true
//For the normal request show the contactForm page. with the send variable set to true
return 'true';
}
}