1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Seeder; |
4
|
|
|
|
5
|
|
|
class CBSeeder extends Seeder |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Run the database seeds. |
9
|
|
|
* |
10
|
|
|
* @return void |
11
|
|
|
*/ |
12
|
|
|
public function run() |
13
|
|
|
{ |
14
|
|
|
$this->command->info('Please wait updating the data...'); |
15
|
|
|
|
16
|
|
|
$this->call('Cms_usersSeeder'); |
17
|
|
|
$this->call('Cms_modulsSeeder'); |
18
|
|
|
$this->call('Cms_privilegesSeeder'); |
19
|
|
|
$this->call('Cms_privileges_rolesSeeder'); |
20
|
|
|
$this->call('Cms_settingsSeeder'); |
21
|
|
|
$this->call('CmsEmailTemplates'); |
22
|
|
|
|
23
|
|
|
$this->command->info('Updating the data completed !'); |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
class CmsEmailTemplates extends Seeder |
28
|
|
|
{ |
29
|
|
|
public function run() |
30
|
|
|
{ |
31
|
|
|
DB::table('cms_email_templates')->insert([ |
32
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
33
|
|
|
'name' => 'Email Template Forgot Password Backend', |
34
|
|
|
'slug' => 'forgot_password_backend', |
35
|
|
|
'content' => '<p>Hi,</p><p>Someone requested forgot password, here is your new password : </p><p>[password]</p><p><br></p><p>--</p><p>Regards,</p><p>Admin</p>', |
36
|
|
|
'description' => '[password]', |
37
|
|
|
'from_name' => 'System', |
38
|
|
|
'from_email' => '[email protected]', |
39
|
|
|
'cc_email' => null, |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
class Cms_settingsSeeder extends Seeder |
45
|
|
|
{ |
46
|
|
|
public function run() |
47
|
|
|
{ |
48
|
|
|
|
49
|
|
|
$data = [ |
50
|
|
|
|
51
|
|
|
//LOGIN REGISTER STYLE |
52
|
|
|
[ |
53
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
54
|
|
|
'name' => 'login_background_color', |
55
|
|
|
'label' => 'Login Background Color', |
56
|
|
|
'content' => null, |
57
|
|
|
'content_input_type' => 'text', |
58
|
|
|
'group_setting' => trans('crudbooster.login_register_style'), |
59
|
|
|
'dataenum' => null, |
60
|
|
|
'helper' => 'Input hexacode', |
61
|
|
|
], |
62
|
|
|
[ |
63
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
64
|
|
|
'name' => 'login_font_color', |
65
|
|
|
'label' => 'Login Font Color', |
66
|
|
|
'content' => null, |
67
|
|
|
'content_input_type' => 'text', |
68
|
|
|
'group_setting' => trans('crudbooster.login_register_style'), |
69
|
|
|
'dataenum' => null, |
70
|
|
|
'helper' => 'Input hexacode', |
71
|
|
|
], |
72
|
|
|
[ |
73
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
74
|
|
|
'name' => 'login_background_image', |
75
|
|
|
'label' => 'Login Background Image', |
76
|
|
|
'content' => null, |
77
|
|
|
'content_input_type' => 'upload_image', |
78
|
|
|
'group_setting' => trans('crudbooster.login_register_style'), |
79
|
|
|
'dataenum' => null, |
80
|
|
|
'helper' => null, |
81
|
|
|
], |
82
|
|
|
|
83
|
|
|
//EMAIL SETTING |
84
|
|
|
[ |
85
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
86
|
|
|
'name' => 'email_sender', |
87
|
|
|
'label' => 'Email Sender', |
88
|
|
|
'content' => '[email protected]', |
89
|
|
|
'content_input_type' => 'text', |
90
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
91
|
|
|
'dataenum' => null, |
92
|
|
|
'helper' => null, |
93
|
|
|
], |
94
|
|
|
[ |
95
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
96
|
|
|
'name' => 'smtp_driver', |
97
|
|
|
'label' => 'Mail Driver', |
98
|
|
|
'content' => 'mail', |
99
|
|
|
'content_input_type' => 'select', |
100
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
101
|
|
|
'dataenum' => 'smtp,mail,sendmail', |
102
|
|
|
'helper' => null, |
103
|
|
|
], |
104
|
|
|
[ |
105
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
106
|
|
|
'name' => 'smtp_host', |
107
|
|
|
'label' => 'SMTP Host', |
108
|
|
|
'content' => '', |
109
|
|
|
'content_input_type' => 'text', |
110
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
111
|
|
|
'dataenum' => null, |
112
|
|
|
'helper' => null, |
113
|
|
|
], |
114
|
|
|
[ |
115
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
116
|
|
|
'name' => 'smtp_port', |
117
|
|
|
'label' => 'SMTP Port', |
118
|
|
|
'content' => '25', |
119
|
|
|
'content_input_type' => 'text', |
120
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
121
|
|
|
'dataenum' => null, |
122
|
|
|
'helper' => 'default 25', |
123
|
|
|
], |
124
|
|
|
[ |
125
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
126
|
|
|
'name' => 'smtp_username', |
127
|
|
|
'label' => 'SMTP Username', |
128
|
|
|
'content' => '', |
129
|
|
|
'content_input_type' => 'text', |
130
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
131
|
|
|
'dataenum' => null, |
132
|
|
|
'helper' => null, |
133
|
|
|
], |
134
|
|
|
[ |
135
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
136
|
|
|
'name' => 'smtp_password', |
137
|
|
|
'label' => 'SMTP Password', |
138
|
|
|
'content' => '', |
139
|
|
|
'content_input_type' => 'text', |
140
|
|
|
'group_setting' => trans('crudbooster.email_setting'), |
141
|
|
|
'dataenum' => null, |
142
|
|
|
'helper' => null, |
143
|
|
|
], |
144
|
|
|
|
145
|
|
|
//APPLICATION SETTING |
146
|
|
|
[ |
147
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
148
|
|
|
'name' => 'appname', |
149
|
|
|
'label' => 'Application Name', |
150
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
151
|
|
|
'content' => 'CRUDBooster', |
152
|
|
|
'content_input_type' => 'text', |
153
|
|
|
'dataenum' => null, |
154
|
|
|
'helper' => null, |
155
|
|
|
], |
156
|
|
|
[ |
157
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
158
|
|
|
'name' => 'default_paper_size', |
159
|
|
|
'label' => 'Default Paper Print Size', |
160
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
161
|
|
|
'content' => 'Legal', |
162
|
|
|
'content_input_type' => 'text', |
163
|
|
|
'dataenum' => null, |
164
|
|
|
'helper' => 'Paper size, ex : A4, Legal, etc', |
165
|
|
|
], |
166
|
|
|
[ |
167
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
168
|
|
|
'name' => 'logo', |
169
|
|
|
'label' => 'Logo', |
170
|
|
|
'content' => '', |
171
|
|
|
'content_input_type' => 'upload_image', |
172
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
173
|
|
|
'dataenum' => null, |
174
|
|
|
'helper' => null, |
175
|
|
|
], |
176
|
|
|
[ |
177
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
178
|
|
|
'name' => 'favicon', |
179
|
|
|
'label' => 'Favicon', |
180
|
|
|
'content' => '', |
181
|
|
|
'content_input_type' => 'upload_image', |
182
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
183
|
|
|
'dataenum' => null, |
184
|
|
|
'helper' => null, |
185
|
|
|
], |
186
|
|
|
[ |
187
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
188
|
|
|
'name' => 'api_debug_mode', |
189
|
|
|
'label' => 'API Debug Mode', |
190
|
|
|
'content' => 'true', |
191
|
|
|
'content_input_type' => 'select', |
192
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
193
|
|
|
'dataenum' => 'true,false', |
194
|
|
|
'helper' => null, |
195
|
|
|
], |
196
|
|
|
[ |
197
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
198
|
|
|
'name' => 'google_api_key', |
199
|
|
|
'label' => 'Google API Key', |
200
|
|
|
'content' => '', |
201
|
|
|
'content_input_type' => 'text', |
202
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
203
|
|
|
'dataenum' => null, |
204
|
|
|
'helper' => null, |
205
|
|
|
], |
206
|
|
|
[ |
207
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
208
|
|
|
'name' => 'google_fcm_key', |
209
|
|
|
'label' => 'Google FCM Key', |
210
|
|
|
'content' => '', |
211
|
|
|
'content_input_type' => 'text', |
212
|
|
|
'group_setting' => trans('crudbooster.application_setting'), |
213
|
|
|
'dataenum' => null, |
214
|
|
|
'helper' => null, |
215
|
|
|
], |
216
|
|
|
]; |
217
|
|
|
|
218
|
|
|
foreach ($data as $row) { |
219
|
|
|
$count = DB::table('cms_settings')->where('name', $row['name'])->count(); |
220
|
|
|
if ($count) { |
221
|
|
|
if ($count > 1) { |
222
|
|
|
$newsId = DB::table('cms_settings')->where('name', $row['name'])->orderby('id', 'asc')->take(1)->first(); |
223
|
|
|
DB::table('cms_settings')->where('name', $row['name'])->where('id', '!=', $newsId->id)->delete(); |
224
|
|
|
} |
225
|
|
|
continue; |
226
|
|
|
} |
227
|
|
|
DB::table('cms_settings')->insert($row); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
class Cms_privileges_rolesSeeder extends Seeder |
233
|
|
|
{ |
234
|
|
|
public function run() |
235
|
|
|
{ |
236
|
|
|
|
237
|
|
|
if (DB::table('cms_privileges_roles')->count() == 0) { |
238
|
|
|
$modules = DB::table('cms_moduls')->get(); |
239
|
|
|
$i = 1; |
240
|
|
|
foreach ($modules as $module) { |
241
|
|
|
|
242
|
|
|
$is_visible = 1; |
243
|
|
|
$is_create = 1; |
244
|
|
|
$is_read = 1; |
245
|
|
|
$is_edit = 1; |
246
|
|
|
$is_delete = 1; |
247
|
|
|
|
248
|
|
|
switch ($module->table_name) { |
249
|
|
|
case 'cms_logs': |
250
|
|
|
$is_create = 0; |
251
|
|
|
$is_edit = 0; |
252
|
|
|
break; |
253
|
|
|
case 'cms_privileges_roles': |
254
|
|
|
$is_visible = 0; |
255
|
|
|
break; |
256
|
|
|
case 'cms_apicustom': |
257
|
|
|
$is_visible = 0; |
258
|
|
|
break; |
259
|
|
|
case 'cms_notifications': |
260
|
|
|
$is_create = $is_read = $is_edit = $is_delete = 0; |
261
|
|
|
break; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
DB::table('cms_privileges_roles')->insert([ |
265
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
266
|
|
|
'is_visible' => $is_visible, |
267
|
|
|
'is_create' => $is_create, |
268
|
|
|
'is_edit' => $is_edit, |
269
|
|
|
'is_delete' => $is_delete, |
270
|
|
|
'is_read' => $is_read, |
271
|
|
|
'id_cms_privileges' => 1, |
272
|
|
|
'id_cms_moduls' => $module->id, |
273
|
|
|
]); |
274
|
|
|
$i++; |
275
|
|
|
} |
276
|
|
|
} |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
class Cms_privilegesSeeder extends Seeder |
281
|
|
|
{ |
282
|
|
|
public function run() |
283
|
|
|
{ |
284
|
|
|
|
285
|
|
|
if (DB::table('cms_privileges')->where('name', 'Super Administrator')->count() == 0) { |
286
|
|
|
DB::table('cms_privileges')->insert([ |
287
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
288
|
|
|
'name' => 'Super Administrator', |
289
|
|
|
'is_superadmin' => 1, |
290
|
|
|
'theme_color' => 'skin-red', |
291
|
|
|
]); |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
class Cms_modulsSeeder extends Seeder |
297
|
|
|
{ |
298
|
|
|
public function run() |
299
|
|
|
{ |
300
|
|
|
|
301
|
|
|
/* |
302
|
|
|
1 = Public |
303
|
|
|
2 = Setting |
304
|
|
|
*/ |
305
|
|
|
|
306
|
|
|
$data = [ |
307
|
|
|
[ |
308
|
|
|
|
309
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
310
|
|
|
'name' => trans('crudbooster.Notifications'), |
311
|
|
|
'icon' => 'fa fa-cog', |
312
|
|
|
'path' => 'notifications', |
313
|
|
|
'table_name' => 'cms_notifications', |
314
|
|
|
'controller' => 'NotificationsController', |
315
|
|
|
'is_protected' => 1, |
316
|
|
|
'is_active' => 1, |
317
|
|
|
], |
318
|
|
|
[ |
319
|
|
|
|
320
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
321
|
|
|
'name' => trans('crudbooster.Privileges'), |
322
|
|
|
'icon' => 'fa fa-cog', |
323
|
|
|
'path' => 'privileges', |
324
|
|
|
'table_name' => 'cms_privileges', |
325
|
|
|
'controller' => 'PrivilegesController', |
326
|
|
|
'is_protected' => 1, |
327
|
|
|
'is_active' => 1, |
328
|
|
|
], |
329
|
|
|
[ |
330
|
|
|
|
331
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
332
|
|
|
'name' => trans('crudbooster.Privileges_Roles'), |
333
|
|
|
'icon' => 'fa fa-cog', |
334
|
|
|
'path' => 'privileges_roles', |
335
|
|
|
'table_name' => 'cms_privileges_roles', |
336
|
|
|
'controller' => 'PrivilegesRolesController', |
337
|
|
|
'is_protected' => 1, |
338
|
|
|
'is_active' => 1, |
339
|
|
|
], |
340
|
|
|
[ |
341
|
|
|
|
342
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
343
|
|
|
'name' => trans('crudbooster.Users_Management'), |
344
|
|
|
'icon' => 'fa fa-users', |
345
|
|
|
'path' => 'users', |
346
|
|
|
'table_name' => 'cms_users', |
347
|
|
|
'controller' => 'AdminCmsUsersController', |
348
|
|
|
'is_protected' => 0, |
349
|
|
|
'is_active' => 1, |
350
|
|
|
], |
351
|
|
|
[ |
352
|
|
|
|
353
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
354
|
|
|
'name' => trans('crudbooster.settings'), |
355
|
|
|
'icon' => 'fa fa-cog', |
356
|
|
|
'path' => 'settings', |
357
|
|
|
'table_name' => 'cms_settings', |
358
|
|
|
'controller' => 'SettingsController', |
359
|
|
|
'is_protected' => 1, |
360
|
|
|
'is_active' => 1, |
361
|
|
|
], |
362
|
|
|
[ |
363
|
|
|
|
364
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
365
|
|
|
'name' => trans('crudbooster.Module_Generator'), |
366
|
|
|
'icon' => 'fa fa-database', |
367
|
|
|
'path' => 'module_generator', |
368
|
|
|
'table_name' => 'cms_moduls', |
369
|
|
|
'controller' => 'ModulsController', |
370
|
|
|
'is_protected' => 1, |
371
|
|
|
'is_active' => 1, |
372
|
|
|
], |
373
|
|
|
[ |
374
|
|
|
|
375
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
376
|
|
|
'name' => trans('crudbooster.Menu_Management'), |
377
|
|
|
'icon' => 'fa fa-bars', |
378
|
|
|
'path' => 'menu_management', |
379
|
|
|
'table_name' => 'cms_menus', |
380
|
|
|
'controller' => 'MenusController', |
381
|
|
|
'is_protected' => 1, |
382
|
|
|
'is_active' => 1, |
383
|
|
|
], |
384
|
|
|
[ |
385
|
|
|
|
386
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
387
|
|
|
'name' => trans('crudbooster.Email_Templates'), |
388
|
|
|
'icon' => 'fa fa-envelope-o', |
389
|
|
|
'path' => 'email_templates', |
390
|
|
|
'table_name' => 'cms_email_templates', |
391
|
|
|
'controller' => 'EmailTemplatesController', |
392
|
|
|
'is_protected' => 1, |
393
|
|
|
'is_active' => 1, |
394
|
|
|
], |
395
|
|
|
[ |
396
|
|
|
|
397
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
398
|
|
|
'name' => trans('crudbooster.Statistic_Builder'), |
399
|
|
|
'icon' => 'fa fa-dashboard', |
400
|
|
|
'path' => 'statistic_builder', |
401
|
|
|
'table_name' => 'cms_statistics', |
402
|
|
|
'controller' => 'StatisticBuilderController', |
403
|
|
|
'is_protected' => 1, |
404
|
|
|
'is_active' => 1, |
405
|
|
|
], |
406
|
|
|
[ |
407
|
|
|
|
408
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
409
|
|
|
'name' => trans('crudbooster.API_Generator'), |
410
|
|
|
'icon' => 'fa fa-cloud-download', |
411
|
|
|
'path' => 'api_generator', |
412
|
|
|
'table_name' => '', |
413
|
|
|
'controller' => 'ApiCustomController', |
414
|
|
|
'is_protected' => 1, |
415
|
|
|
'is_active' => 1, |
416
|
|
|
], |
417
|
|
|
[ |
418
|
|
|
|
419
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
420
|
|
|
'name' => trans('crudbooster.Log_User_Access'), |
421
|
|
|
'icon' => 'fa fa-flag-o', |
422
|
|
|
'path' => 'logs', |
423
|
|
|
'table_name' => 'cms_logs', |
424
|
|
|
'controller' => 'LogsController', |
425
|
|
|
'is_protected' => 1, |
426
|
|
|
'is_active' => 1, |
427
|
|
|
], |
428
|
|
|
]; |
429
|
|
|
|
430
|
|
|
foreach ($data as $k => $d) { |
431
|
|
|
if (DB::table('cms_moduls')->where('name', $d['name'])->count()) { |
432
|
|
|
unset($data[$k]); |
433
|
|
|
} |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
DB::table('cms_moduls')->insert($data); |
437
|
|
|
} |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
class Cms_usersSeeder extends Seeder |
441
|
|
|
{ |
442
|
|
|
public function run() |
443
|
|
|
{ |
444
|
|
|
|
445
|
|
|
if (DB::table('cms_users')->count() == 0) { |
446
|
|
|
$password = \Hash::make('123456'); |
447
|
|
|
$cms_users = DB::table('cms_users')->insert([ |
|
|
|
|
448
|
|
|
'created_at' => date('Y-m-d H:i:s'), |
449
|
|
|
'name' => 'Super Admin', |
450
|
|
|
'email' => '[email protected]', |
451
|
|
|
'password' => $password, |
452
|
|
|
'id_cms_privileges' => 1, |
453
|
|
|
'status' => 'Active', |
454
|
|
|
]); |
455
|
|
|
} |
456
|
|
|
} |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
|