feat: initialize general settings table with validation constraints and database seeder

This commit is contained in:
Yoga Pangestu 2026-04-22 22:18:55 +07:00
parent 703ceefddf
commit f84173e8aa
4 changed files with 28 additions and 5 deletions

View File

@ -26,7 +26,7 @@ public function rules(): array
$settingExists = GeneralSetting::exists();
return [
'name' => ['required', 'string', 'max:255'],
'name' => ['required', 'string', 'max:50'],
'description' => ['required', 'string'],
'address' => ['required', 'string'],
'phone' => ['required', 'string', 'max:20'],

View File

@ -13,10 +13,10 @@ public function up(): void
{
Schema::create('general_settings', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->text('address')->nullable();
$table->string('phone')->nullable();
$table->string('name', 50);
$table->text('description');
$table->text('address');
$table->string('phone', 20);
$table->timestamps();
});
}

View File

@ -20,6 +20,7 @@ public function run(): void
ExpenseSeeder::class,
PurchaseSeeder::class,
OrderSeeder::class,
GeneralSettingSeeder::class,
]);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Database\Seeders;
use App\Models\GeneralSetting;
use Illuminate\Database\Seeder;
class GeneralSettingSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
GeneralSetting::updateOrCreate([
'name' => 'VN Grup',
'description' => 'VN Grup adalah Toko Baju Daster Online yang menghadirkan koleksi baju daster berkualitas tinggi untuk wanita yang mengutamakan kenyamanan tanpa mengorbankan gaya. Kami menyediakan berbagai macam daster dengan desain yang beragam, mulai dari yang sederhana dan klasik hingga yang modern dan trendi, cocok untuk berbagai kebutuhan, baik di rumah maupun saat bersantai di luar.',
'address' => 'Jl. Raya Pabuaran-Cipeunduy, Kec. Pabuaran, Kab. Subang, Jawa Barat',
'phone' => '089679965828',
]);
}
}