Codebase update

- Remove default pic assignments for unsold commodity notifications
- Check wabot credential complete first before notification blast, if incomplete no notification be sent
- Change migration column order for settings table, column group first
- Resolve error of not showing select after updating any PIC for selected day
This commit is contained in:
Afiq Hamzah
2024-06-10 18:32:02 +08:00
parent 3686fb93de
commit 119f6d6428
6 changed files with 176 additions and 58 deletions
@@ -1,37 +0,0 @@
<?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' => [[]],
'pic_monday' => [[]],
'pic_tuesday' => [[]],
'pic_wednesday' => [[]],
'pic_thursday' => [[]],
'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]);
}
}
}
@@ -12,6 +12,8 @@ class UnsoldCommodityNotificationSettingSeeders extends Seeder
*/
public function run()
{
Setting::where('group', 'unsold_commodity_notifications')->each(fn($x) => $x->delete());
$data = [
[
'key' => 'status',
@@ -39,43 +41,43 @@ class UnsoldCommodityNotificationSettingSeeders extends Seeder
],
[
'key' => 'pic_sunday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Sunday',
],
[
'key' => 'pic_monday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Monday',
],
[
'key' => 'pic_tuesday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Tuesday',
],
[
'key' => 'pic_wednesday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Wednesday',
],
[
'key' => 'pic_thursday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Thursday',
],
[
'key' => 'pic_friday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Friday',
],
[
'key' => 'pic_saturday',
'value' => '',
'value' => '[{}]',
'group' => 'unsold_commodity_notifications',
'description' => 'Person Incharge on Saturday',
],