81 lines
7.7 KiB
PHP
81 lines
7.7 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Employee;
|
|
use App\Models\StockMovement;
|
|
use App\Models\UniformItem;
|
|
use App\Models\User;
|
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
User::updateOrCreate(
|
|
['email' => env('ADMIN_EMAIL', 'admin@uniformflow.local')],
|
|
['name' => 'System Administrator', 'password' => env('ADMIN_PASSWORD', 'Admin@12345'), 'is_admin' => true, 'email_verified_at' => now()]
|
|
);
|
|
|
|
$employees = [
|
|
['employee_no' => 'EMP-001', 'name' => 'Nadeesha Perera', 'department' => 'Operations', 'designation' => 'Operations Executive', 'joined_at' => '2024-02-12'],
|
|
['employee_no' => 'EMP-002', 'name' => 'Kasun Silva', 'department' => 'Warehouse', 'designation' => 'Store Assistant', 'joined_at' => '2023-08-21'],
|
|
['employee_no' => 'EMP-003', 'name' => 'Tharushi Fernando', 'department' => 'Front Office', 'designation' => 'Receptionist', 'joined_at' => '2025-01-15'],
|
|
['employee_no' => 'EMP-004', 'name' => 'Dinuka Jayasinghe', 'department' => 'Security', 'designation' => 'Security Officer', 'joined_at' => '2024-05-06'],
|
|
['employee_no' => 'EMP-005', 'name' => 'Sachini Wickramasinghe', 'department' => 'Housekeeping', 'designation' => 'Room Attendant', 'joined_at' => '2025-03-17'],
|
|
['employee_no' => 'EMP-006', 'name' => 'Lahiru Madushanka', 'department' => 'Maintenance', 'designation' => 'Maintenance Technician', 'joined_at' => '2023-11-02'],
|
|
['employee_no' => 'EMP-007', 'name' => 'Amaya Gunawardena', 'department' => 'Human Resources', 'designation' => 'HR Executive', 'joined_at' => '2024-09-23'],
|
|
['employee_no' => 'EMP-008', 'name' => 'Ravindu Senanayake', 'department' => 'Food & Beverage', 'designation' => 'Service Associate', 'joined_at' => '2025-06-09'],
|
|
['employee_no' => 'EMP-009', 'name' => 'Shenali de Silva', 'department' => 'Finance', 'designation' => 'Accounts Assistant', 'joined_at' => '2024-07-01'],
|
|
['employee_no' => 'EMP-010', 'name' => 'Isuru Bandara', 'department' => 'Kitchen', 'designation' => 'Commis Chef', 'joined_at' => '2025-02-10'],
|
|
['employee_no' => 'EMP-011', 'name' => 'Piumi Karunaratne', 'department' => 'Sales & Marketing', 'designation' => 'Sales Coordinator', 'joined_at' => '2024-10-14'],
|
|
['employee_no' => 'EMP-012', 'name' => 'Dulanjana Herath', 'department' => 'IT', 'designation' => 'IT Support Officer', 'joined_at' => '2025-04-21'],
|
|
];
|
|
|
|
foreach ($employees as $employee) {
|
|
Employee::updateOrCreate(['employee_no' => $employee['employee_no']], $employee);
|
|
}
|
|
|
|
$catalogue = [
|
|
['code' => 'SHIRT-NVY', 'name' => 'Navy Work Shirt', 'material' => '65% polyester, 35% cotton twill', 'color' => 'Navy blue', 'description' => 'Short-sleeve regular-fit operations shirt with chest pocket.', 'care_instructions' => 'Machine wash at 30 C. Warm iron. Do not bleach.', 'unit_value' => 2850, 'sizes' => ['S' => 8, 'M' => 14, 'L' => 9, 'XL' => 3], 'returned' => ['M' => 2, 'L' => 1]],
|
|
['code' => 'TROUSER-GRY', 'name' => 'Grey Work Trouser', 'material' => 'Poly-viscose suiting fabric', 'color' => 'Charcoal grey', 'description' => 'Straight-leg work trouser with reinforced side pockets.', 'care_instructions' => 'Machine wash cold. Line dry. Medium iron.', 'unit_value' => 3650, 'sizes' => ['28' => 4, '30' => 9, '32' => 12, '34' => 6, '36' => 2], 'returned' => ['30' => 1, '32' => 2]],
|
|
['code' => 'POLO-WHT', 'name' => 'White Polo Shirt', 'material' => '220 GSM cotton pique', 'color' => 'White', 'description' => 'Unisex polo shirt with ribbed collar and embroidered logo area.', 'care_instructions' => 'Wash whites separately at 30 C. Do not tumble dry.', 'unit_value' => 2250, 'sizes' => ['S' => 7, 'M' => 10, 'L' => 5, 'XL' => 2], 'returned' => ['S' => 1, 'M' => 1]],
|
|
['code' => 'SEC-SHIRT', 'name' => 'Security Officer Shirt', 'material' => 'Durable polyester-cotton ripstop', 'color' => 'Light blue', 'description' => 'Epaulette security shirt with two buttoned chest pockets.', 'care_instructions' => 'Machine wash at 30 C. Close buttons before washing.', 'unit_value' => 3300, 'sizes' => ['S' => 6, 'M' => 12, 'L' => 10, 'XL' => 5, '2XL' => 2], 'returned' => ['M' => 2, 'L' => 1]],
|
|
['code' => 'HK-TUNIC', 'name' => 'Housekeeping Tunic', 'material' => 'Easy-care polyester stretch blend', 'color' => 'Teal and charcoal', 'description' => 'Side-vent housekeeping tunic with concealed front fastening.', 'care_instructions' => 'Machine wash at 40 C. Low tumble dry. Cool iron.', 'unit_value' => 2750, 'sizes' => ['XS' => 4, 'S' => 9, 'M' => 11, 'L' => 7, 'XL' => 3], 'returned' => ['S' => 1, 'M' => 2]],
|
|
['code' => 'CHEF-COAT', 'name' => 'White Chef Coat', 'material' => 'Heavyweight cotton drill', 'color' => 'White', 'description' => 'Double-breasted long-sleeve chef coat with thermometer pocket.', 'care_instructions' => 'Hot wash up to 60 C. Wash separately. Hot iron.', 'unit_value' => 3150, 'sizes' => ['S' => 5, 'M' => 8, 'L' => 8, 'XL' => 4, '2XL' => 2], 'returned' => ['L' => 1]],
|
|
['code' => 'VEST-HV', 'name' => 'High Visibility Safety Vest', 'material' => 'Fluorescent polyester mesh with reflective tape', 'color' => 'Fluorescent yellow', 'description' => 'Lightweight high-visibility vest with front hook-and-loop closure.', 'care_instructions' => 'Gentle wash at 30 C. Do not iron reflective tape.', 'unit_value' => 1450, 'sizes' => ['S' => 8, 'M' => 15, 'L' => 14, 'XL' => 7, '2XL' => 4], 'returned' => ['M' => 2, 'L' => 2, 'XL' => 1]],
|
|
['code' => 'BLAZER-BLK', 'name' => 'Black Front Office Blazer', 'material' => 'Premium poly-wool suiting blend', 'color' => 'Black', 'description' => 'Single-breasted tailored blazer with two-button closure.', 'care_instructions' => 'Dry clean only. Store on a shaped hanger.', 'unit_value' => 8950, 'sizes' => ['XS' => 2, 'S' => 5, 'M' => 7, 'L' => 5, 'XL' => 2], 'returned' => ['M' => 1]],
|
|
];
|
|
|
|
foreach ($catalogue as $data) {
|
|
$item = UniformItem::updateOrCreate(['code' => $data['code']], [
|
|
'name' => $data['name'],
|
|
'material' => $data['material'],
|
|
'color' => $data['color'],
|
|
'description' => $data['description'],
|
|
'care_instructions' => $data['care_instructions'],
|
|
]);
|
|
foreach ($data['sizes'] as $size => $newQuantity) {
|
|
$returnedQuantity = $data['returned'][$size] ?? 0;
|
|
$variant = $item->variants()->firstOrCreate(['size' => $size], [
|
|
'quantity' => $newQuantity + $returnedQuantity,
|
|
'new_quantity' => $newQuantity,
|
|
'returned_quantity' => $returnedQuantity,
|
|
'unit_value' => $data['unit_value'],
|
|
'reorder_level' => 4,
|
|
]);
|
|
if ($variant->wasRecentlyCreated && $newQuantity) {
|
|
StockMovement::create(['stock_variant_id' => $variant->id, 'type' => 'opening_stock', 'quantity_change' => $newQuantity, 'stock_category' => 'new', 'unit_value' => $data['unit_value'], 'notes' => 'Opening new-stock balance']);
|
|
}
|
|
if ($variant->wasRecentlyCreated && $returnedQuantity) {
|
|
StockMovement::create(['stock_variant_id' => $variant->id, 'type' => 'opening_stock', 'quantity_change' => $returnedQuantity, 'stock_category' => 'returned', 'unit_value' => $data['unit_value'], 'notes' => 'Opening returned-stock balance']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|