Implement seeders instead of seeding using migrations, log whatasapp message
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use App\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UnsoldCommodityNotificationPICSeeders extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$data_pic = [
|
||||
'pic_sunday' => [
|
||||
[
|
||||
'id' => 366, // nurasiah@pkb.net.my
|
||||
'no_telefon' => '0123456789',
|
||||
]
|
||||
],
|
||||
'pic_monday' => [
|
||||
[
|
||||
'id' => 343, // syada@pkb.net.my
|
||||
'no_telefon' => '0139403344',
|
||||
],
|
||||
[
|
||||
'id' => 54, // shahmin@pkb.net.my
|
||||
'no_telefon' => '0196438873',
|
||||
]
|
||||
],
|
||||
'pic_tuesday' => [
|
||||
[
|
||||
'id' => 55, // manita@pkb.net.my
|
||||
'no_telefon' => '0179545432',
|
||||
]
|
||||
],
|
||||
'pic_wednesday' => [
|
||||
[
|
||||
'id' => 52, // izzudin@pkb.net.my
|
||||
'no_telefon' => '0199011095',
|
||||
]
|
||||
],
|
||||
'pic_thursday' => [
|
||||
[
|
||||
'id' => 53, // norosmini@pkb.net.my
|
||||
'no_telefon' => '0129493588',
|
||||
],
|
||||
[
|
||||
'id' => 56, // rozarina@pkb.net.my
|
||||
'no_telefon' => '0129616201',
|
||||
],
|
||||
],
|
||||
'pic_friday' => [[]],
|
||||
'pic_saturday' => [[]],
|
||||
];
|
||||
|
||||
$transformed_data = array_map(function($pic){
|
||||
return json_encode($pic);
|
||||
}, $data_pic);
|
||||
|
||||
$outputs = array_combine(array_keys($data_pic), $transformed_data);
|
||||
|
||||
foreach ($outputs as $key => $data) {
|
||||
Setting::where('group', 'unsold_commodity_notifications')
|
||||
->where('key', $key)
|
||||
->update(['value' => $data]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
use App\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UnsoldCommodityNotificationSettingSeeders extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
'key' => 'status',
|
||||
'value' => '1',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Turn on or turn off notification for unsold commodity notifications',
|
||||
],
|
||||
[
|
||||
'key' => 'start_time',
|
||||
'value' => '20:00',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'The time the notifications start',
|
||||
],
|
||||
[
|
||||
'key' => 'end_time',
|
||||
'value' => '23:00',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'The time the notifications end',
|
||||
],
|
||||
[
|
||||
'key' => 'message',
|
||||
'value' => 'Baki komoditi masih lagi berbaki dan belum habis dijual',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Turn on or turn off notification for unsold commodity notifications',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_sunday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Sunday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_monday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Monday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_tuesday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Tuesday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_wednesday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Wednesday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_thursday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Thursday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_friday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Friday',
|
||||
],
|
||||
[
|
||||
'key' => 'pic_saturday',
|
||||
'value' => '',
|
||||
'group' => 'unsold_commodity_notifications',
|
||||
'description' => 'Person Incharge on Saturday',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
array_walk($data, function ($setting) {
|
||||
Setting::create($setting);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user