Implement seeders instead of seeding using migrations, log whatasapp message

This commit is contained in:
Afiq Hamzah
2024-06-05 16:04:39 +08:00
parent cbf6bd5f1f
commit ab6ee95d64
5 changed files with 114 additions and 32 deletions
@@ -21,6 +21,10 @@ class CreateSettingsTable extends Migration
$table->text('description')->nullable();
$table->timestamps();
});
// Call the seeder
(new UnsoldCommodityNotificationSettingSeeders())->run();
(new UnsoldCommodityNotificationPICSeeders())->run();
}
/**
@@ -1,100 +0,0 @@
<?php
use App\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class AddUnsoldCommoditiesSettings extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$data = [
[
'key' => 'status',
'value' => 'true',
'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);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('settings');
}
}