File: D:/HostingSpaces/SBogers10/ste.komma.pro/app/Forms/AdviseController.php
<?php
namespace App\Forms;
use App\Base\Controller;
use App\C4\C4;
use App\C4\Requests\PutInfoRequest;
use App\Http\Requests\IntakeRequest;
use App\Pages\PageController;
final class AdviseController extends Controller
{
/**
* @var FormService
*/
private $formService;
/**
* ContactController constructor.
* @param FormService $formService
*/
public function __construct(FormService $formService)
{
parent::__construct();
$this->formService = $formService;
$this->formService->setOrigin('advice');
}
/**
* Store the request and send it by e-mail
* Note: Validation is done in the request itself
*
* @param IntakeRequest $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function process(IntakeRequest $request)
{
// Store request in the database
$this->formService->storeRequest($request);
$c4Request = app()->make(PutInfoRequest::class);
$c4Request->fill($request->except('_token'));
$c4Request->assignFormToFormMessage('Formulier: Adviesgesprek');
// Manually set other required attributes
$c4Request->interestedIn = 'OV';
$c4Request->language = 'OVR';
$c4Client = app()->make(C4::class);
$c4Client->putInfoRequest($c4Request);
// Remove token from request (this creates and array)
// Mail::send(new AdviseMail($request->except('_token')));
// Return json response with
return redirect(localized_route('advise.success'));
}
/**
* Show page where we thank the user
*
* @return mixed
*/
public function success()
{
$pageController = new PageController();
return $pageController->show($this->links->advise->node)->with('send', true);
}
}