File: D:/HostingSpaces/SBogers10/wingssprayer.komma.pro/app/Forms/PlanDemoController.php
<?php
/**
* Created by PhpStorm.
* User: mike
* Date: 26/09/17
* Time: 15:24
*/
namespace App\Forms;
use App\Base\Controller;
use App\Http\Requests\ContactRequest;
use App\Http\Requests\PlanDemoRequest;
use App\Mail\PlanDemoMail;
use App\Pages\PageController;
use App\Mail\ContactMail;
use Illuminate\Support\Facades\Mail;
final class PlanDemoController extends Controller
{
/**
* @var FormService
*/
private $formService;
/**
* PlanDemoController constructor.
* @param FormService $formService
*/
public function __construct(FormService $formService)
{
parent::__construct();
$this->formService = $formService;
$this->formService->setOrigin('plan_demo');
}
/**
* Store the request and send it by e-mail
* Note: Validation is done in the request itself
*
* @param PlanDemoRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function process(PlanDemoRequest $request)
{
// Store request in the database
$this->formService->storeRequest($request);
// Remove token from request (this creates and array)
Mail::send(new PlanDemoMail($request->except('_token')));
// Redirect to the success page
return redirect(localized_route('plan_demo.success'));
}
/**
* Show page where we thank the user
*
* @return mixed
*/
public function success()
{
$pageController = new PageController();
return $pageController->show($this->links->plan_demo->node)->with('send', true);
}
}