HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/ste.komma.pro/app/Forms/ContactController.php
<?php

namespace App\Forms;

use App\Base\Controller;
use App\C4\C4;
use App\C4\Requests\PutInfoRequest;
use App\Http\Requests\ContactRequest;
use App\Pages\PageController;

final class ContactController extends Controller
{
    /**
     * @var FormService
     */
    private $formService;

    /**
     * ContactController constructor.
     * @param FormService $formService
     */
    public function __construct(FormService $formService)
    {
        parent::__construct();

        $this->formService = $formService;
        $this->formService->setOrigin('contact');
    }

    /**
     * Store the request and send it by e-mail
     * Note: Validation is done in the request itself
     *
     * @param  ContactRequest  $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function process(ContactRequest $request)
    {
        // Check for secret code
        if ($request->input('_willie') !== 'wonka') {
            return response()->json([
                'errors' => [
                    '_secretCode' => [
                        __('validation.secretCode')
                    ],
                ],
            ], 422);
        }

        // Store request in the database
        $this->formService->storeRequest($request);

        $c4Request = app()->make(PutInfoRequest::class);
        $c4Request->fill($request->except('_token', '_willie', '_honey'));
        $c4Request->assignFormToFormMessage('Formulier: Contact');

        // Manually set other required attributes
        $c4Request->interestedIn = 'OV';
        $c4Request->language = 'OVR';

        $c4Client = app()->make(C4::class);
        $c4Client->putInfoRequest($c4Request);

//        Mail::send(new ContactMail($request->except('_token', '_willie', '_honey')));

        // Return json response with
        return response()->json([
            'redirectUrl' => route('contact.success')
        ]);
    }

    /**
     * Show page where we thank the user
     *
     * @return mixed
     */
    public function success()
    {
        $pageController = new PageController();
        return $pageController->show($this->links->contact->node)->with('send', true);
    }
}