district require is optional

This commit is contained in:
vedatakd 2021-03-25 12:41:34 +03:00
parent ca771cf280
commit 98bcc6ac13
6 changed files with 36 additions and 17 deletions

View File

@ -15,7 +15,7 @@ function Locations(cat, level, name) {
url: "/class/ajax", url: "/class/ajax",
success: function (msg) { success: function (msg) {
$('select[name="' + name + '"]').find('option').remove(); $('select[name="' + name + '"]').find('option').remove();
$('select[name="' + name + '"]').append('<option>...</option>'); $('select[name="' + name + '"]').append('<option value="">...</option>');
$.each(msg, function (key, value) { $.each(msg, function (key, value) {
$('select[name="' + name + '"]').append('<option value="' + value.id + '">' + value.name + '</option>'); $('select[name="' + name + '"]').append('<option value="' + value.id + '">' + value.name + '</option>');
}); });

View File

@ -7,6 +7,7 @@ return [
'general_setting' => [ 'general_setting' => [
'title' => 'visiosoft.module.profile::section.general_setting', 'title' => 'visiosoft.module.profile::section.general_setting',
'fields' => [ 'fields' => [
'required_district',
'show_my_ads', 'show_my_ads',
'upload_avatar', 'upload_avatar',
'show_tax_office', 'show_tax_office',

View File

@ -70,4 +70,10 @@ return [
"education" => "anomaly.field_type.tags", "education" => "anomaly.field_type.tags",
"state_of_education" => "anomaly.field_type.tags", "state_of_education" => "anomaly.field_type.tags",
"profession" => "anomaly.field_type.tags", "profession" => "anomaly.field_type.tags",
'required_district' => [
'type' => 'anomaly.field_type.boolean',
'config' => [
'default_value' => false,
]
],
]; ];

View File

@ -47,4 +47,7 @@ return [
'name' => 'Hide Register Type in Profile Page', 'name' => 'Hide Register Type in Profile Page',
'instructions' => 'Hides the register type field in the profile edit page.', 'instructions' => 'Hides the register type field in the profile edit page.',
], ],
'required_district' => [
'name' => 'Required District'
],
]; ];

View File

@ -26,7 +26,9 @@ class AdressFormFields
'city' => [ 'city' => [
'required' => true, 'required' => true,
], ],
'district', 'district' => [
'required' => setting_value( 'visiosoft.module.profile::required_district'),
],
'adress_content' => [ 'adress_content' => [
'required' => true, 'required' => true,
], ],

View File

@ -134,8 +134,15 @@ class MyProfileController extends PublicController
{ {
$message = []; $message = [];
$error_district = false;
if (setting_value('visiosoft.module.profile::required_district') and (!$this->request->district or $this->request->district == "")) {
$error_district = true;
}
$error = $form->build()->validate()->getFormErrors()->getMessages(); $error = $form->build()->validate()->getFormErrors()->getMessages();
if (!empty($error)) {
if (!empty($error) or $error_district) {
$this->messages->flush();
$message['status'] = "error"; $message['status'] = "error";
$message['msg'] = trans('visiosoft.module.profile::message.required_all'); $message['msg'] = trans('visiosoft.module.profile::message.required_all');
return $message; return $message;
@ -248,19 +255,19 @@ class MyProfileController extends PublicController
return response()->json(['status' => 'success', 'data' => $profile]); return response()->json(['status' => 'success', 'data' => $profile]);
} }
public function getEducation(Request $request) public function getEducation(Request $request)
{ {
$user = $this->userRepository->find(auth()->id()); $user = $this->userRepository->find(auth()->id());
$education = EducationModel::all(); $education = EducationModel::all();
$educationPart = EducationPartModel::query()->where('education_id', $user->education)->get(); $educationPart = EducationPartModel::query()->where('education_id', $user->education)->get();
return response()->json(['user' => $user, 'education' => $education, 'education-part' => $educationPart], 200); return response()->json(['user' => $user, 'education' => $education, 'education-part' => $educationPart], 200);
} }
public function changeEducation(Request $request) public function changeEducation(Request $request)
{ {
if ($request->info == 'education') { if ($request->info == 'education') {
$education = EducationPartModel::query()->where('education_id', $request->education)->get(); $education = EducationPartModel::query()->where('education_id', $request->education)->get();
} }
return response()->json(['data' => $education], 200); return response()->json(['data' => $education], 200);
} }
} }