CreateSettingsTable::populateDummyData()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 190
Code Lines 170

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 170
nc 2
nop 0
dl 0
loc 190
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use Illuminate\Database\Migrations\Migration;
5
use Illuminate\Database\Schema\Blueprint;
6
use Illuminate\Support\Facades\Artisan;
7
use Illuminate\Support\Facades\Hash;
8
use Illuminate\Support\Facades\Schema;
9
use Pratiksh\Adminetic\Models\Admin\Role;
10
11
class CreateSettingsTable extends Migration
12
{
13
    /**
14
     * Run the migrations.
15
     *
16
     * @return void
17
     */
18
    public function up()
19
    {
20
        Schema::create('settings', function (Blueprint $table) {
21
            $table->id();
22
            $table->string('setting_name');
23
            $table->string('string_value')->nullable();
24
            $table->integer('integer_value')->nullable();
25
            $table->text('text_value')->nullable();
26
            $table->boolean('boolean_value')->nullable();
27
            $table->json('setting_json')->nullable();
28
            $table->json('setting_custom')->nullable();
29
            $table->integer('setting_type');
30
            $table->string('setting_group')->default('general');
31
            $table->timestamps();
32
        });
33
34
        $this->populateDummyData();
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        Schema::dropIfExists('settings');
45
    }
46
47
    private function populateDummyData()
48
    {
49
        // Migrate with dummy
50
        if (config('adminetic.migrate_with_dummy', false)) {
51
            Artisan::call('make:permission Role 2 --onlyFlags');
52
            Artisan::call('make:permission Permission 2 --onlyFlags');
53
            Artisan::call('make:permission User 2 --onlyFlags');
54
55
            Artisan::call('make:permission Setting 2 --onlyFlags');
56
            Artisan::call('make:permission Preference 2 --onlyFlags');
57
58
            $admin = User::create([
59
                'name' => 'Admin User',
60
                'email' => '[email protected]',
61
                'password' => Hash::make('admin123'),
62
            ]);
63
64
            $role = Role::where('name', 'admin')->first();
65
66
            $admin->roles()->attach($role);
67
            $admin->profile()->create();
68
        }
69
        \DB::table('settings')->insert([
70
            0 => [
71
                'id' => 5,
72
                'setting_name' => 'logo',
73
                'string_value' => null,
74
                'integer_value' => null,
75
                'text_value' => null,
76
                'boolean_value' => null,
77
                'setting_json' => null,
78
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"logo\\",\\r\\n    \\"id\\": \\"logo\\"\\r\\n}"',
79
                'setting_type' => 10,
80
                'setting_group' => 'multimedia',
81
                'created_at' => '2023-03-23 08:19:08',
82
                'updated_at' => '2023-03-23 08:19:08',
83
            ],
84
            1 => [
85
                'id' => 6,
86
                'setting_name' => 'favicon',
87
                'string_value' => null,
88
                'integer_value' => null,
89
                'text_value' => null,
90
                'boolean_value' => null,
91
                'setting_json' => null,
92
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"favicon\\",\\r\\n    \\"id\\": \\"favicon\\"\\r\\n}"',
93
                'setting_type' => 10,
94
                'setting_group' => 'multimedia',
95
                'created_at' => '2023-03-23 08:19:26',
96
                'updated_at' => '2023-03-23 08:19:26',
97
            ],
98
            2 => [
99
                'id' => 7,
100
                'setting_name' => 'dark_logo',
101
                'string_value' => null,
102
                'integer_value' => null,
103
                'text_value' => null,
104
                'boolean_value' => null,
105
                'setting_json' => null,
106
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"dark_logo\\",\\r\\n    \\"id\\": \\"dark_logo\\"\\r\\n}"',
107
                'setting_type' => 10,
108
                'setting_group' => 'multimedia',
109
                'created_at' => '2023-03-23 08:19:45',
110
                'updated_at' => '2023-03-23 08:19:45',
111
            ],
112
            3 => [
113
                'id' => 8,
114
                'setting_name' => 'logobanner',
115
                'string_value' => null,
116
                'integer_value' => null,
117
                'text_value' => null,
118
                'boolean_value' => null,
119
                'setting_json' => null,
120
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"logoBanner\\",\\r\\n    \\"id\\": \\"logoBanner\\"\\r\\n}"',
121
                'setting_type' => 10,
122
                'setting_group' => 'multimedia',
123
                'created_at' => '2023-03-23 08:20:00',
124
                'updated_at' => '2023-03-23 08:20:00',
125
            ],
126
            4 => [
127
                'id' => 9,
128
                'setting_name' => 'login_register_bg_image',
129
                'string_value' => null,
130
                'integer_value' => null,
131
                'text_value' => null,
132
                'boolean_value' => null,
133
                'setting_json' => null,
134
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"login_register_bg_image\\",\\r\\n    \\"id\\": \\"login_register_bg_image\\"\\r\\n}"',
135
                'setting_type' => 10,
136
                'setting_group' => 'multimedia',
137
                'created_at' => '2023-03-23 08:20:15',
138
                'updated_at' => '2023-03-23 08:20:15',
139
            ],
140
            5 => [
141
                'id' => 10,
142
                'setting_name' => 'title',
143
                'string_value' => null,
144
                'integer_value' => null,
145
                'text_value' => null,
146
                'boolean_value' => null,
147
                'setting_json' => null,
148
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"title\\",\\r\\n    \\"id\\": \\"title\\",\\r\\n    \\"placeholder\\": \\"Site Title Here!!\\"\\r\\n}"',
149
                'setting_type' => 1,
150
                'setting_group' => 'general',
151
                'created_at' => '2023-03-23 08:20:41',
152
                'updated_at' => '2023-03-23 08:20:41',
153
            ],
154
            6 => [
155
                'id' => 11,
156
                'setting_name' => 'description',
157
                'string_value' => null,
158
                'integer_value' => null,
159
                'text_value' => null,
160
                'boolean_value' => null,
161
                'setting_json' => null,
162
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"description\\",\\r\\n    \\"id\\": \\"description\\"\\r\\n}"',
163
                'setting_type' => 3,
164
                'setting_group' => 'general',
165
                'created_at' => '2023-03-23 08:23:45',
166
                'updated_at' => '2023-03-23 08:23:45',
167
            ],
168
            7 => [
169
                'id' => 12,
170
                'setting_name' => 'phone',
171
                'string_value' => null,
172
                'integer_value' => null,
173
                'text_value' => null,
174
                'boolean_value' => null,
175
                'setting_json' => null,
176
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"phone\\",\\r\\n    \\"id\\": \\"phone\\",\\r\\n    \\"placeholder\\": \\"Phone Number\\",\\r\\n    \\"max\\": 9899999999,\\r\\n    \\"min\\": 9000000000\\r\\n}"',
177
                'setting_type' => 1,
178
                'setting_group' => 'general',
179
                'created_at' => '2023-03-23 08:24:52',
180
                'updated_at' => '2023-03-23 08:24:52',
181
            ],
182
            8 => [
183
                'id' => 13,
184
                'setting_name' => 'email',
185
                'string_value' => null,
186
                'integer_value' => null,
187
                'text_value' => null,
188
                'boolean_value' => null,
189
                'setting_json' => null,
190
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"email\\",\\r\\n    \\"id\\": \\"email\\",\\r\\n    \\"placeholder\\": \\"Email Address\\"\\r\\n}"',
191
                'setting_type' => 1,
192
                'setting_group' => 'general',
193
                'created_at' => '2023-03-23 08:25:21',
194
                'updated_at' => '2023-03-23 08:25:21',
195
            ],
196
            9 => [
197
                'id' => 14,
198
                'setting_name' => 'currency',
199
                'string_value' => null,
200
                'integer_value' => null,
201
                'text_value' => null,
202
                'boolean_value' => null,
203
                'setting_json' => null,
204
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"currency\\",\\r\\n    \\"id\\": \\"currency\\",\\r\\n    \\"value\\": \\"Rs.\\",\\r\\n    \\"placeholder\\": \\"Currency Symbol\\"\\r\\n}"',
205
                'setting_type' => 1,
206
                'setting_group' => 'general',
207
                'created_at' => '2023-03-23 08:25:50',
208
                'updated_at' => '2023-03-23 08:25:50',
209
            ],
210
            11 => [
211
                'id' => 16,
212
                'setting_name' => 'map',
213
                'string_value' => null,
214
                'integer_value' => null,
215
                'text_value' => null,
216
                'boolean_value' => null,
217
                'setting_json' => null,
218
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"map\\",\\r\\n    \\"id\\": \\"map\\"\\r\\n}"',
219
                'setting_type' => 3,
220
                'setting_group' => 'general',
221
                'created_at' => '2023-03-23 08:27:44',
222
                'updated_at' => '2023-03-23 08:27:44',
223
            ],
224
            12 => [
225
                'id' => 17,
226
                'setting_name' => 'address',
227
                'string_value' => null,
228
                'integer_value' => null,
229
                'text_value' => null,
230
                'boolean_value' => null,
231
                'setting_json' => null,
232
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"address\\",\\r\\n    \\"id\\": \\"address\\",\\r\\n    \\"placeholder\\": \\"Address Here\\"\\r\\n}"',
233
                'setting_type' => 1,
234
                'setting_group' => 'general',
235
                'created_at' => '2023-03-23 08:28:27',
236
                'updated_at' => '2023-03-23 08:28:27',
237
            ],
238
        ]);
239
    }
240
}
241