Passed
Push — main ( bfff7a...f85971 )
by PRATIK
13:07
created

CreateSettingsTable::populateDummyData()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 217
Code Lines 196

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 196
nc 2
nop 0
dl 0
loc 217
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(array(
70
            0 =>
71
            array(
72
                'id' => 5,
73
                'setting_name' => 'logo',
74
                'string_value' => NULL,
75
                'integer_value' => NULL,
76
                'text_value' => NULL,
77
                'boolean_value' => NULL,
78
                'setting_json' => NULL,
79
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"logo\\",\\r\\n    \\"id\\": \\"logo\\"\\r\\n}"',
80
                'setting_type' => 10,
81
                'setting_group' => 'multimedia',
82
                'created_at' => '2023-03-23 08:19:08',
83
                'updated_at' => '2023-03-23 08:19:08',
84
            ),
85
            1 =>
86
            array(
87
                'id' => 6,
88
                'setting_name' => 'favicon',
89
                'string_value' => NULL,
90
                'integer_value' => NULL,
91
                'text_value' => NULL,
92
                'boolean_value' => NULL,
93
                'setting_json' => NULL,
94
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"favicon\\",\\r\\n    \\"id\\": \\"favicon\\"\\r\\n}"',
95
                'setting_type' => 10,
96
                'setting_group' => 'multimedia',
97
                'created_at' => '2023-03-23 08:19:26',
98
                'updated_at' => '2023-03-23 08:19:26',
99
            ),
100
            2 =>
101
            array(
102
                'id' => 7,
103
                'setting_name' => 'dark_logo',
104
                'string_value' => NULL,
105
                'integer_value' => NULL,
106
                'text_value' => NULL,
107
                'boolean_value' => NULL,
108
                'setting_json' => NULL,
109
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"dark_logo\\",\\r\\n    \\"id\\": \\"dark_logo\\"\\r\\n}"',
110
                'setting_type' => 10,
111
                'setting_group' => 'multimedia',
112
                'created_at' => '2023-03-23 08:19:45',
113
                'updated_at' => '2023-03-23 08:19:45',
114
            ),
115
            3 =>
116
            array(
117
                'id' => 8,
118
                'setting_name' => 'logobanner',
119
                'string_value' => NULL,
120
                'integer_value' => NULL,
121
                'text_value' => NULL,
122
                'boolean_value' => NULL,
123
                'setting_json' => NULL,
124
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"logoBanner\\",\\r\\n    \\"id\\": \\"logoBanner\\"\\r\\n}"',
125
                'setting_type' => 10,
126
                'setting_group' => 'multimedia',
127
                'created_at' => '2023-03-23 08:20:00',
128
                'updated_at' => '2023-03-23 08:20:00',
129
            ),
130
            4 =>
131
            array(
132
                'id' => 9,
133
                'setting_name' => 'login_register_bg_image',
134
                'string_value' => NULL,
135
                'integer_value' => NULL,
136
                'text_value' => NULL,
137
                'boolean_value' => NULL,
138
                'setting_json' => NULL,
139
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"login_register_bg_image\\",\\r\\n    \\"id\\": \\"login_register_bg_image\\"\\r\\n}"',
140
                'setting_type' => 10,
141
                'setting_group' => 'multimedia',
142
                'created_at' => '2023-03-23 08:20:15',
143
                'updated_at' => '2023-03-23 08:20:15',
144
            ),
145
            5 =>
146
            array(
147
                'id' => 10,
148
                'setting_name' => 'title',
149
                'string_value' => NULL,
150
                'integer_value' => NULL,
151
                'text_value' => NULL,
152
                'boolean_value' => NULL,
153
                'setting_json' => NULL,
154
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"title\\",\\r\\n    \\"id\\": \\"title\\",\\r\\n    \\"placeholder\\": \\"Site Title Here!!\\"\\r\\n}"',
155
                'setting_type' => 1,
156
                'setting_group' => 'general',
157
                'created_at' => '2023-03-23 08:20:41',
158
                'updated_at' => '2023-03-23 08:20:41',
159
            ),
160
            6 =>
161
            array(
162
                'id' => 11,
163
                'setting_name' => 'description',
164
                'string_value' => NULL,
165
                'integer_value' => NULL,
166
                'text_value' => NULL,
167
                'boolean_value' => NULL,
168
                'setting_json' => NULL,
169
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"description\\",\\r\\n    \\"id\\": \\"description\\"\\r\\n}"',
170
                'setting_type' => 3,
171
                'setting_group' => 'general',
172
                'created_at' => '2023-03-23 08:23:45',
173
                'updated_at' => '2023-03-23 08:23:45',
174
            ),
175
            7 =>
176
            array(
177
                'id' => 12,
178
                'setting_name' => 'phone',
179
                'string_value' => NULL,
180
                'integer_value' => NULL,
181
                'text_value' => NULL,
182
                'boolean_value' => NULL,
183
                'setting_json' => NULL,
184
                '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}"',
185
                'setting_type' => 2,
186
                'setting_group' => 'general',
187
                'created_at' => '2023-03-23 08:24:52',
188
                'updated_at' => '2023-03-23 08:24:52',
189
            ),
190
            8 =>
191
            array(
192
                'id' => 13,
193
                'setting_name' => 'email',
194
                'string_value' => NULL,
195
                'integer_value' => NULL,
196
                'text_value' => NULL,
197
                'boolean_value' => NULL,
198
                'setting_json' => NULL,
199
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"email\\",\\r\\n    \\"id\\": \\"email\\",\\r\\n    \\"placeholder\\": \\"Email Address\\"\\r\\n}"',
200
                'setting_type' => 1,
201
                'setting_group' => 'general',
202
                'created_at' => '2023-03-23 08:25:21',
203
                'updated_at' => '2023-03-23 08:25:21',
204
            ),
205
            9 =>
206
            array(
207
                'id' => 14,
208
                'setting_name' => 'currency',
209
                'string_value' => NULL,
210
                'integer_value' => NULL,
211
                'text_value' => NULL,
212
                'boolean_value' => NULL,
213
                'setting_json' => NULL,
214
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"currency\\",\\r\\n    \\"id\\": \\"currency\\",\\r\\n    \\"value\\": \\"Rs.\\",\\r\\n    \\"placeholder\\": \\"Currency Symbol\\"\\r\\n}"',
215
                'setting_type' => 1,
216
                'setting_group' => 'general',
217
                'created_at' => '2023-03-23 08:25:50',
218
                'updated_at' => '2023-03-23 08:25:50',
219
            ),
220
            10 =>
221
            array(
222
                'id' => 15,
223
                'setting_name' => 'date_mode',
224
                'string_value' => NULL,
225
                'integer_value' => NULL,
226
                'text_value' => NULL,
227
                'boolean_value' => NULL,
228
                'setting_json' => NULL,
229
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"date_mode\\",\\r\\n    \\"id\\": \\"date_mode\\",\\r\\n    \\"default\\": \\"1\\",\\r\\n    \\"options\\": {\\r\\n        \\"bs\\": \\"bs\\",\\r\\n        \\"ad\\": \\"ad\\"\\r\\n    }\\r\\n}"',
230
                'setting_type' => 7,
231
                'setting_group' => 'general',
232
                'created_at' => '2023-03-23 08:27:12',
233
                'updated_at' => '2023-03-23 08:27:12',
234
            ),
235
            11 =>
236
            array(
237
                'id' => 16,
238
                'setting_name' => 'map',
239
                'string_value' => NULL,
240
                'integer_value' => NULL,
241
                'text_value' => NULL,
242
                'boolean_value' => NULL,
243
                'setting_json' => NULL,
244
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"map\\",\\r\\n    \\"id\\": \\"map\\"\\r\\n}"',
245
                'setting_type' => 3,
246
                'setting_group' => 'general',
247
                'created_at' => '2023-03-23 08:27:44',
248
                'updated_at' => '2023-03-23 08:27:44',
249
            ),
250
            12 =>
251
            array(
252
                'id' => 17,
253
                'setting_name' => 'address',
254
                'string_value' => NULL,
255
                'integer_value' => NULL,
256
                'text_value' => NULL,
257
                'boolean_value' => NULL,
258
                'setting_json' => NULL,
259
                'setting_custom' => '"{\\r\\n    \\"class\\": \\"address\\",\\r\\n    \\"id\\": \\"address\\",\\r\\n    \\"placeholder\\": \\"Address Here\\"\\r\\n}"',
260
                'setting_type' => 1,
261
                'setting_group' => 'general',
262
                'created_at' => '2023-03-23 08:28:27',
263
                'updated_at' => '2023-03-23 08:28:27',
264
            ),
265
        ));
266
    }
267
}
268