remove command prompt

This commit is contained in:
Diatrex 2020-10-13 09:16:55 +03:00
parent 83f6f9207d
commit 6ee0ce02a9

View File

@ -26,177 +26,175 @@ class UsersFieldsSeeder extends Seeder
AssignmentModelTranslation $assignmentModelTranslation
)
{
if ($this->command->confirm('This command will remove the old custom fields from the users table! Are you sure you want to continue?')) {
$namespace = 'users';
$locked = 0;
$stream = $streamRepository->findBySlugAndNamespace('users', 'users');
$namespace = 'users';
$locked = 0;
$stream = $streamRepository->findBySlugAndNamespace('users', 'users');
$customFields = [
0 => [
'name' => 'File',
'slug' => 'file',
'type' => 'visiosoft.field_type.singlefile',
'config' => [
'folders' => ["images"],
'mode' => 'upload',
]
$customFields = [
0 => [
'name' => 'File',
'slug' => 'file',
'type' => 'visiosoft.field_type.singlefile',
'config' => [
'folders' => ["images"],
'mode' => 'upload',
]
],
1 => [
'name' => 'Country',
'slug' => 'country',
'type' => 'anomaly.field_type.relationship',
'config' => [
'related' => CountryModel::class,
"default_value" => 0,
],
1 => [
'name' => 'Country',
'slug' => 'country',
'type' => 'anomaly.field_type.relationship',
'config' => [
'related' => CountryModel::class,
"default_value" => 0,
],
2 => [
'name' => 'City',
'slug' => 'city',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [],
]
],
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 => [
'name' => 'City',
'slug' => 'city',
'type' => 'anomaly.field_type.select',
"config" => [
"options" => [],
]
],
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')
],
]
],
10 => [
'name' => 'Identification Number',
'slug' => 'identification_number',
'type' => 'anomaly.field_type.text',
],
11 => [
'name' => 'Notified New Updates',
'slug' => 'notified_new_updates',
'type' => 'anomaly.field_type.select',
'config' => [
'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' => trans('visiosoft.module.profile::field.birthday.name'),
'slug' => 'birthday',
'type' => 'anomaly.field_type.datetime',
'config' => [
"mode" => "date",
"picker" => true,
]
],
];
]
],
10 => [
'name' => 'Identification Number',
'slug' => 'identification_number',
'type' => 'anomaly.field_type.text',
],
11 => [
'name' => 'Notified New Updates',
'slug' => 'notified_new_updates',
'type' => 'anomaly.field_type.select',
'config' => [
'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' => trans('visiosoft.module.profile::field.birthday.name'),
'slug' => 'birthday',
'type' => 'anomaly.field_type.datetime',
'config' => [
"mode" => "date",
"picker" => true,
]
],
];
foreach ($customFields as $customField) {
$fields = $fieldRepository
->newQuery()
->where('slug', $customField['slug'])
->where('namespace', $namespace)
->get();
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();
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();
$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
]);
}
$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
]);
}
}
}