#2220 points module

This commit is contained in:
Diatrex 2020-10-09 16:34:40 +03:00
parent 6c77ce4109
commit 15ffa5646b
6 changed files with 180 additions and 158 deletions

View File

@ -114,4 +114,10 @@
} }
} }
} }
#nav-details {
.birthday-field .input-group-addon {
display: none;
}
}
} }

View File

@ -55,6 +55,9 @@ return [
'register_type' => [ 'register_type' => [
'name' => 'Register Type' 'name' => 'Register Type'
], ],
'birthday' => [
'name' => 'Birthday'
],
'identification_number' => [ 'identification_number' => [
'name' => 'Identification Number' 'name' => 'Identification Number'
], ],

View File

@ -151,7 +151,9 @@
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label class="control-label font-weight-bold">{{ trans("visiosoft.module.profile::field.register_type.name") }}</label> <label class="control-label font-weight-bold">
{{ trans("visiosoft.module.profile::field.register_type.name") }}
</label>
{{ profileForm.fields.register_type.input|raw }} {{ profileForm.fields.register_type.input|raw }}
</div> </div>
</div> </div>

View File

@ -13,6 +13,7 @@ class ProfileFormBuilder extends FormBuilder
'office_phone', 'office_phone',
'land_phone', 'land_phone',
'identification_number', 'identification_number',
'birthday',
'register_type' 'register_type'
]; ];

View File

@ -21,6 +21,7 @@ class ProfileFormHandler
'office_phone' => $builder->getPostValue('office_phone'), 'office_phone' => $builder->getPostValue('office_phone'),
'land_phone' => $builder->getPostValue('land_phone'), 'land_phone' => $builder->getPostValue('land_phone'),
'identification_number' => $builder->getPostValue('identification_number'), 'identification_number' => $builder->getPostValue('identification_number'),
'birthday' => $builder->getPostValue('birthday'),
'register_type' => $builder->getPostValue('register_type'), 'register_type' => $builder->getPostValue('register_type'),
]; ];

View File

@ -3,11 +3,9 @@
use Anomaly\Streams\Platform\Assignment\AssignmentModelTranslation; use Anomaly\Streams\Platform\Assignment\AssignmentModelTranslation;
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentRepositoryInterface; use Anomaly\Streams\Platform\Assignment\Contract\AssignmentRepositoryInterface;
use Anomaly\Streams\Platform\Database\Seeder\Seeder; use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Anomaly\Streams\Platform\Entry\EntryTranslationsModel;
use Anomaly\Streams\Platform\Field\Contract\FieldRepositoryInterface; use Anomaly\Streams\Platform\Field\Contract\FieldRepositoryInterface;
use Anomaly\Streams\Platform\Field\FieldModelTranslation; use Anomaly\Streams\Platform\Field\FieldModelTranslation;
use Anomaly\Streams\Platform\Stream\Contract\StreamRepositoryInterface; use Anomaly\Streams\Platform\Stream\Contract\StreamRepositoryInterface;
use Anomaly\Streams\Platform\Stream\StreamModelTranslation;
use Visiosoft\LocationModule\Country\CountryModel; use Visiosoft\LocationModule\Country\CountryModel;
class UsersFieldsSeeder extends Seeder class UsersFieldsSeeder extends Seeder
@ -28,166 +26,177 @@ class UsersFieldsSeeder extends Seeder
AssignmentModelTranslation $assignmentModelTranslation AssignmentModelTranslation $assignmentModelTranslation
) )
{ {
$namespace = 'users'; if ($this->command->confirm('This command will remove the old custom fields from the users table! Are you sure you want to continue?')) {
$locked = 0; $namespace = 'users';
$stream = $streamRepository->findBySlugAndNamespace('users', 'users'); $locked = 0;
$stream = $streamRepository->findBySlugAndNamespace('users', 'users');
$customFields = [ $customFields = [
0 => [ 0 => [
'name' => 'File', 'name' => 'File',
'slug' => 'file', 'slug' => 'file',
'type' => 'visiosoft.field_type.singlefile', 'type' => 'visiosoft.field_type.singlefile',
'config' => [ 'config' => [
'folders' => ["images"], 'folders' => ["images"],
'mode' => 'upload', 'mode' => 'upload',
] ]
],
1 => [
'name' => 'Country',
'slug' => 'country',
'type' => 'anomaly.field_type.relationship',
'config' => [
'related' => CountryModel::class,
"default_value" => 0,
], ],
], 1 => [
2 => [ 'name' => 'Country',
'name' => 'City', 'slug' => 'country',
'slug' => 'city', 'type' => 'anomaly.field_type.relationship',
'type' => 'anomaly.field_type.select', 'config' => [
"config" => [ 'related' => CountryModel::class,
"options" => [], "default_value" => 0,
]
],
3 => [
'name' => 'District',
'slug' => 'district',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [],
]
],
4 => [
'name' => 'Neighborhood',
'slug' => 'neighborhood',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [],
]
],
5 => [
'name' => 'Village',
'slug' => 'village',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [],
]
],
6 => [
'name' => 'Gsm Phone',
'slug' => 'gsm_phone',
'type' => 'anomaly.field_type.text',
],
7 => [
'name' => 'Land Phone',
'slug' => 'land_phone',
'type' => 'anomaly.field_type.text',
],
8 => [
'name' => 'Office Phone',
'slug' => 'office_phone',
'type' => 'anomaly.field_type.text',
],
9 => [
'name' => 'Register Type',
'slug' => 'register_type',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [
'1' => trans('visiosoft.module.profile::field.individual.name'),
'2' => trans('visiosoft.module.profile::field.corporate.name')
], ],
] ],
], 2 => [
10 => [ 'name' => 'City',
'name' => 'Identification Number', 'slug' => 'city',
'slug' => 'identification_number', 'type' => 'anomaly.field_type.select',
'type' => 'anomaly.field_type.text', "config" => [
], "options" => [],
11 => [ ]
'name' => 'Notified New Updates', ],
'slug' => 'notified_new_updates', 3 => [
'type' => 'anomaly.field_type.select', 'name' => 'District',
'config' => [ 'slug' => 'district',
'default_value' => 1, 'type' => 'anomaly.field_type.select',
'options' => [0 => 'Active', 1 => 'Passive'], "config" => [
'separator' => ':', "options" => [],
] ]
], ],
12 => [ 4 => [
'name' => 'Notified About Ads', 'name' => 'Neighborhood',
'slug' => 'notified_about_ads', 'slug' => 'neighborhood',
'type' => 'anomaly.field_type.select', 'type' => 'anomaly.field_type.select',
'config' => [ "config" => [
'default_value' => 1, "options" => [],
'options' => [0 => 'Active', 1 => 'Passive'], ]
'separator' => ':', ],
] 5 => [
], 'name' => 'Village',
13 => [ 'slug' => 'village',
'name' => 'Receive Messages Email', 'type' => 'anomaly.field_type.select',
'slug' => 'receive_messages_email', "config" => [
'type' => 'anomaly.field_type.select', "options" => [],
'config' => [ ]
'default_value' => 1, ],
'options' => [0 => 'Active', 1 => 'Passive'], 6 => [
'separator' => ':', 'name' => 'Gsm Phone',
] 'slug' => 'gsm_phone',
], 'type' => 'anomaly.field_type.text',
]; ],
7 => [
foreach ($customFields as $customField) { 'name' => 'Land Phone',
$fields = $fieldRepository 'slug' => 'land_phone',
->newQuery() 'type' => 'anomaly.field_type.text',
->where('slug', $customField['slug']) ],
->where('namespace', $namespace) 8 => [
->get(); 'name' => 'Office Phone',
'slug' => 'office_phone',
if ($fields) { 'type' => 'anomaly.field_type.text',
foreach ($fields as $field) { ],
$fieldModelTranslation->newQuery()->where('field_id', $field->id)->delete(); 9 => [
'name' => 'Register Type',
$assignment = $assignmentRepository 'slug' => 'register_type',
->newQuery() 'type' => 'anomaly.field_type.select',
->where('stream_id', $stream->id) "config" => [
->where('field_id', $field->id) "options" => [
->first(); '1' => trans('visiosoft.module.profile::field.individual.name'),
if ($assignment) { '2' => trans('visiosoft.module.profile::field.corporate.name')
$assignmentModelTranslation->newQuery()->where('assignment_id', $assignment->id)->delete(); ],
$assignment->delete(); ]
} ],
10 => [
$field->delete(); 'name' => 'Identification Number',
} 'slug' => 'identification_number',
} 'type' => 'anomaly.field_type.text',
],
$data = [ 11 => [
'name' => $customField['name'], 'name' => 'Notified New Updates',
'namespace' => $namespace, 'slug' => 'notified_new_updates',
'slug' => $customField['slug'], 'type' => 'anomaly.field_type.select',
'type' => $customField['type'], 'config' => [
'locked' => $locked 'default_value' => 1,
'options' => [0 => 'Active', 1 => 'Passive'],
'separator' => ':',
]
],
12 => [
'name' => 'Notified About Ads',
'slug' => 'notified_about_ads',
'type' => 'anomaly.field_type.select',
'config' => [
'default_value' => 1,
'options' => [0 => 'Active', 1 => 'Passive'],
'separator' => ':',
]
],
13 => [
'name' => 'Receive Messages Email',
'slug' => 'receive_messages_email',
'type' => 'anomaly.field_type.select',
'config' => [
'default_value' => 1,
'options' => [0 => 'Active', 1 => 'Passive'],
'separator' => ':',
]
],
14 => [
'name' => 'Birthday',
'slug' => 'birthday',
'type' => 'anomaly.field_type.datetime',
'config' => [
"mode" => "date",
"picker" => true,
]
],
]; ];
if (isset($customField['config'])) {
$data['config'] = $customField['config']; foreach ($customFields as $customField) {
$fields = $fieldRepository
->newQuery()
->where('slug', $customField['slug'])
->where('namespace', $namespace)
->get();
if ($fields) {
foreach ($fields as $field) {
$fieldModelTranslation->newQuery()->where('field_id', $field->id)->delete();
$assignment = $assignmentRepository
->newQuery()
->where('stream_id', $stream->id)
->where('field_id', $field->id)
->first();
if ($assignment) {
$assignmentModelTranslation->newQuery()->where('assignment_id', $assignment->id)->delete();
$assignment->delete();
}
$field->delete();
}
}
$data = [
'name' => $customField['name'],
'namespace' => $namespace,
'slug' => $customField['slug'],
'type' => $customField['type'],
'locked' => $locked
];
if (isset($customField['config'])) {
$data['config'] = $customField['config'];
}
$field = $fieldRepository->create($data);
$assignmentRepository->create([
'stream_id' => $stream->id,
'field_id' => $field->id
]);
} }
$field = $fieldRepository->create($data);
$assignmentRepository->create([
'stream_id' => $stream->id,
'field_id' => $field->id
]);
} }
} }
} }