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