#2594 e-madencilik add 3 fields to profile

This commit is contained in:
Diatrex 2020-11-06 18:32:17 +03:00
parent 55277e990f
commit 14e9e47e09
9 changed files with 136 additions and 1 deletions

View File

@ -0,0 +1,69 @@
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
class VisiosoftModuleProfileCreateProfessionAndEducationalFields extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if ($stream = $this->streams()->findBySlugAndNamespace('users', 'users')) {
$fields = [
[
'name' => trans('visiosoft.module.profile::field.education.name'),
'slug' => 'education',
],
[
'name' => trans('visiosoft.module.profile::field.state_of_education.name'),
'slug' => 'state_of_education',
],
[
'name' => trans('visiosoft.module.profile::field.profession.name'),
'slug' => 'profession',
],
];
foreach ($fields as $field) {
$exists = $this->fields()
->newQuery()
->where('slug', $field['slug'])
->where('namespace', 'users')
->first();
if (!$exists) {
$userField = $this->fields()->create([
'name' => $field['name'],
'namespace' => 'users',
'slug' => $field['slug'],
'type' => 'anomaly.field_type.tags',
'locked' => 0,
]);
$this->assignments()->create([
'stream_id' => $stream->id,
'field_id' => $userField->id
]);
}
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/*
* I never go back on my word!
* That's my nindo: my ninja way!
* NARUTO
*/
}
}

View File

@ -141,5 +141,9 @@
.birthday-field .input-group-addon {
display: none;
}
.education-field > .tagify, .state_of_education-field > .tagify, .profession-field > .tagify {
height: initial;
}
}
}

View File

@ -7,7 +7,11 @@ return [
'general_setting' => [
'title' => 'visiosoft.module.profile::section.general_setting',
'fields' => [
'show_my_ads', 'upload_avatar', 'show_tax_office', 'show_checkbox_terms_on_register'
'show_my_ads',
'upload_avatar',
'show_tax_office',
'show_checkbox_terms_on_register',
'show_education_profession'
],
],
'recaptcha' => [

View File

@ -41,4 +41,11 @@ return [
'mode' => 'checkbox'
]
],
'show_education_profession' => [
'type' => 'anomaly.field_type.boolean',
'config' => [
'default_value' => true,
'mode' => 'checkbox'
]
],
];

View File

@ -58,6 +58,15 @@ return [
'birthday' => [
'name' => 'Birthday'
],
'education' => [
'name' => 'Education'
],
'state_of_education' => [
'name' => 'State of Education'
],
'profession' => [
'name' => 'Profession'
],
'identification_number' => [
'name' => 'Identification Number'
],

View File

@ -14,6 +14,10 @@ return [
'name' => 'Show Checkbox Terms on Register',
'instructions' => 'Show the "Accept term", "protection law", "privacy term", "sms & emails" on the register form'
],
'show_education_profession' => [
'name' => 'Show Education and Profession Fields',
'instructions' => 'Show the "Education", "State of Education" and "Profession" on the profile edit page'
],
'google_captcha_site_key' => [
'name' => 'Google Captcha Site Key',
],

View File

@ -149,6 +149,33 @@
{{ profileForm.fields.birthday.input|raw }}
</div>
</div>
{% if setting_value('visiosoft.module.profile::show_education_profession') %}
<div class="col-md-12">
<div class="form-group education-field">
<label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.education.name") }}
</label>
{{ profileForm.fields.education.input|raw }}
</div>
</div>
<div class="col-md-12">
<div class="form-group state_of_education-field">
<label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.state_of_education.name") }}
</label>
{{ profileForm.fields.state_of_education.input|raw }}
</div>
</div>
<div class="col-md-12">
<div class="form-group profession-field">
<label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.profession.name") }}
</label>
{{ profileForm.fields.profession.input|raw }}
</div>
</div>
{% endif %}
<div class="col-md-12">
<div class="form-group">
<label class="control-label font-weight-bold">

View File

@ -13,6 +13,9 @@ class ProfileFormBuilder extends FormBuilder
'office_phone',
'land_phone',
'identification_number',
'education',
'state_of_education',
'profession',
'birthday',
'register_type'
];

View File

@ -25,6 +25,14 @@ class ProfileFormHandler
'register_type' => $builder->getPostValue('register_type'),
];
if (setting_value('visiosoft.module.profile::show_education_profession')) {
$parameters = array_merge($parameters, [
'education' => $builder->getPostValue('education'),
'state_of_education' => $builder->getPostValue('state_of_education'),
'profession' => $builder->getPostValue('profession'),
]);
}
if ($builder->getPostValue('file') != null) {
$parameters['file_id'] = $builder->getPostValue('file');
} elseif (empty($builder->getPostValue('file'))) {