Commit 4f4b8e59 authored by Valentin Kotenko's avatar Valentin Kotenko
Browse files

multilang typeform add

parent 71c8635c
......@@ -43,7 +43,9 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
TYPEFORM_GOV_FORM_ID="Gov registration form ID from Typeform"
TYPEFORM_ORG_FORM_ID="Org registration form ID from Typeform"
TYPEFORM_GOV_FORM_ID_EN="Gov registration form ID from Typeform"
TYPEFORM_GOV_FORM_ID_DE="Gov registration form ID from Typeform"
TYPEFORM_ORG_FORM_ID_EN="Gov registration form ID from Typeform"
TYPEFORM_ORG_FORM_ID_DE="Gov registration form ID from Typeform"
ADMIN_MAIL_FOR_NOTIFICATION="test@test.test"
......@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Lang;
class RegisterController extends Controller
{
......@@ -44,17 +45,23 @@ class RegisterController extends Controller
public function showOrgRegistrationForm()
{
$currentLanguage = Lang::getLocale();
$formId = env('TYPEFORM_ORG_FORM_ID' . '_' . mb_strtoupper($currentLanguage) ?? 'EN', null);
$languages = config('languages', []);
return view('auth.orgRegister', [
return view('auth.register', [
'languages' => $languages,
'form' => $formId
]);
}
public function showGovRegistrationForm()
{
$currentLanguage = Lang::getLocale();
$formId = env('TYPEFORM_GOV_FORM_ID' . '_' . mb_strtoupper($currentLanguage) ?? 'EN', null);
$languages = config('languages', []);
return view('auth.register', [
'languages' => $languages,
'form' => $formId
]);
}
......
......@@ -20,10 +20,12 @@ class UserController extends Controller
{
$formResponse = $request->input('form_response.answers');
if ($request->input('form_response.form_id') === env('TYPEFORM_GOV_FORM_ID', null)) {
$formId = $request->input('form_response.form_id');
if (($formId === env('TYPEFORM_GOV_FORM_ID_EN', null)) || ($formId === env('TYPEFORM_GOV_FORM_ID_DE', null))) {
$isGovUser = true;
$userData = $this->createGovUserData($formResponse);
} elseif ($request->input('form_response.form_id') === env('TYPEFORM_ORG_FORM_ID', null)) {
} elseif (($formId === env('TYPEFORM_ORG_FORM_ID_EN', null)) || ($formId === env('TYPEFORM_ORG_FORM_ID_DE', null))) {
$isGovUser = false;
$userData = $this->createOrgUserData($formResponse);
}
......@@ -73,31 +75,40 @@ class UserController extends Controller
}
switch ($answer['field']['ref']) {
case '2ad2a8a6-400a-4699-b78b-7f42a4f8a4ec':
case '27aced6c-7f38-4437-b891-93b2f2263b5a':
$userData['name'] = $answerData;
break;
case 'ad52f5f3-e173-4c11-902d-13d34b41e601':
case '965d0cf0-ca04-4593-b1fe-e2002be484b0':
$userData['last_name'] = $answerData;
break;
case 'c57e4de3-e883-4505-9d52-606034e74752':
case 'b9126184-2133-4285-8ae5-85f424d6aac7':
$userData['email'] = $answerData;
break;
case '020272f2-2173-477d-84d1-fc40e53c624b':
case '8f43d520-4b2b-4993-8895-3d28268e725e':
$userData['phone'] = $answerData;
break;
case '1161c328-3764-4743-b7f8-2eda7f2125a9':
case '8a78adac-9238-40b9-924f-67c9fcad037d':
$userData['organization'] = $answerData;
break;
case 'eda582a8-3c5f-451c-83bc-a3b07186795e':
case 'c4037a6f-8a6e-44eb-8301-936657d3515c':
$userData['website'] = $answerData;
break;
case '47303d61-9303-4957-af0d-cbf3029d2c03':
case 'd353d4ad-89fc-4223-bc57-6d2050f8f7a0':
$userData['department'] = $answerData;
break;
case '9fbf636b-3849-4d2f-884d-5b86bb2cb83e':
case '0a34395c-c664-4398-93db-587c7f9a1ab5':
$userData['position'] = $answerData;
break;
case '3533923f-a7cf-4cd7-99c0-f812ef8fedd3':
case 'e1ae0c90-3a84-4ed0-b848-b4fa23a54c7d':
$userData['role'] = $answerData;
break;
}
......@@ -128,33 +139,43 @@ class UserController extends Controller
switch ($answer['field']['ref']) {
case '2d8ab4a3-39f8-4b20-bd52-0418e566e536':
case '9991f349-ca82-4f72-8405-172cf51e729b':
$userData['name'] = $answerData;
break;
case '5c1898c2-c048-46ee-9014-9743f54b7285':
case 'a342512c-52de-4dda-b59d-e5dbff953224':
$userData['last_name'] = $answerData;
break;
case 'ab578827-0e41-4a5a-a14a-2f69914f5175':
case 'e7fd179c-2471-4a35-a2c3-10c688464e12':
$userData['email'] = $answerData;
break;
case '4c98e2f3-5c4b-4bf1-98f1-615a4bdc2ef3':
case '9ac69062-6907-43c2-8025-36802220d92e':
$userData['phone'] = $answerData;
break;
case '13d8c2e6-3954-4843-95b9-40845b4cce41':
case '4ec04ea7-5687-46e7-a8f0-cbaa559a2088':
$userData['department'] = $answerData;
break;
case '32d5cf8d-1e0b-4cad-ae2a-0e90e45b994c':
case 'aa426bd2-84bd-4158-bb7e-e10278f11d42':
$userData['position'] = $answerData;
break;
case 'b649bc89-439e-4ed7-935f-b6cf7de58da8':
case 'ebbb1210-8819-40c3-961c-f4541d77c01d':
$userData['organization'] = $answerData;
break;
case 'f6fd3598-b549-4732-b17c-09a87ac23753':
case '9ff8becb-066f-4530-a59a-7fb6157fd2a4':
$userData['website'] = $answerData;
break;
case 'c51b3243-027f-48ed-9bd8-3a185b003478':
case '21b00e95-61ae-41f7-9c11-f5a4f234e128':
$userData['sales'] = $answerData;
break;
case '42746665-5d75-40c1-bebe-de78fb371562':
case '1cb49a7c-07a1-43b8-ae28-622b896e94e3':
$userData['number_of_employees'] = $answerData;
break;
}
......
......@@ -19,10 +19,12 @@ class CheckTypeformIdentifier
public function handle($request, Closure $next)
{
$formId = $request->input('form_response.form_id');
$govId = env('TYPEFORM_GOV_FORM_ID', null);
$orgId = env('TYPEFORM_ORG_FORM_ID', null);
$govId = env('TYPEFORM_GOV_FORM_ID_EN', null);
$govIdDe = env('TYPEFORM_GOV_FORM_ID_DE', null);
$orgId = env('TYPEFORM_ORG_FORM_ID_EN', null);
$orgIdDe = env('TYPEFORM_ORG_FORM_ID_DE', null);
if (($formId === $govId) || ($formId === $orgId)) {
if (($formId === $govId) || ($formId === $orgId) || ($formId === $govIdDe) || ($formId === $orgIdDe)) {
return $next($request);
}
......
......@@ -44,8 +44,8 @@ trait ModelMain
{
$foreignKey = static::$foreingColumn ?: 'row_id';
$currntLanguage = Lang::getLocale();
$language = Language::where('iso6391', $currntLanguage)->first();
$currentLanguage = Lang::getLocale();
$language = Language::where('iso6391', $currentLanguage)->first();
return $this
->hasOne($this->relatedModelName(), $foreignKey, 'id')
......
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div id="my-embedded-typeform"
style="width: 100%; height: 800px;"></div>
<script src="https://embed.typeform.com/embed.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEventListener("DOMContentLoaded", function() {
var el = document.getElementById("my-embedded-typeform");
// When instantiating a widget embed, you must provide the DOM element
// that will contain your typeform, the URL of your typeform, and your
// desired embed settings
window.typeformEmbed.makeWidget(el, "https://govradar.typeform.com/to/mUE91G", {
hideFooter: false,
hideHeaders: false,
opacity: 0
});
});
</script>
</div>
</div>
@endsection
......@@ -13,7 +13,7 @@
// When instantiating a widget embed, you must provide the DOM element
// that will contain your typeform, the URL of your typeform, and your
// desired embed settings
window.typeformEmbed.makeWidget(el, "https://govradar.typeform.com/to/OOi9cp", {
window.typeformEmbed.makeWidget(el, "https://govradar.typeform.com/to/<?php echo ($form); ?>", {
hideFooter: false,
hideHeaders: false,
opacity: 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment