Files
GSB-Construction/Modules/MaterialLogistics/database/seeders/ConstructionMaterialsSeeder.php

238 lines
15 KiB
PHP

<?php
namespace Modules\MaterialLogistics\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
use Modules\MasterData\Models\Material;
use Modules\MasterData\Models\MaterialComponent;
class ConstructionMaterialsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$materials = [
// Concrete & Cement
['name' => 'Portland Cement Type I', 'category' => 'Concrete & Cement', 'unit' => 'Bag (40kg)', 'unit_cost' => 8.50, 'description' => 'General purpose portland cement.'] ,
['name' => 'Portland Cement Type III', 'category' => 'Concrete & Cement', 'unit' => 'Bag (40kg)', 'unit_cost' => 10.00, 'description' => 'High early strength portland cement.'],
['name' => 'Ready Mix Concrete (20 MPa)', 'category' => 'Concrete & Cement', 'unit' => 'Cubic Meter', 'unit_cost' => 110.00, 'description' => 'Standard strength ready mix concrete.'],
['name' => 'Ready Mix Concrete (30 MPa)', 'category' => 'Concrete & Cement', 'unit' => 'Cubic Meter', 'unit_cost' => 130.00, 'description' => 'High strength ready mix concrete.'],
['name' => 'Concrete Blocks (Hollow) 8x8x16', 'category' => 'Concrete & Cement', 'unit' => 'Piece', 'unit_cost' => 1.50, 'description' => 'Standard 8-inch hollow concrete block.'],
['name' => 'Reinforced Concrete Pipes (RCP)', 'category' => 'Concrete & Cement', 'unit' => 'Piece', 'unit_cost' => 150.00, 'description' => 'Reinforced Concrete Pipes (RCP) for drainage lines.'],
// Aggregates
['name' => 'River Sand', 'category' => 'Aggregates', 'unit' => 'Ton', 'unit_cost' => 20.00, 'description' => 'Washed river sand for mixing.'],
['name' => 'Crushed Stone (Gravel) 3/4"', 'category' => 'Aggregates', 'unit' => 'Ton', 'unit_cost' => 25.00, 'description' => '3/4 inch curshed limestone base.'],
['name' => 'Pea Gravel', 'category' => 'Aggregates', 'unit' => 'Ton', 'unit_cost' => 30.00, 'description' => 'Smooth round pea gravel.'],
['name' => 'Base Gravel (Class 5)', 'category' => 'Aggregates', 'unit' => 'Ton', 'unit_cost' => 18.00, 'description' => 'Class 5 aggregate base course material.'],
// Steel & Rebar
['name' => 'Rebar #4 (1/2" x 20 ft)', 'category' => 'Steel & Metal', 'unit' => 'Piece', 'unit_cost' => 6.20, 'description' => 'Standard #4 reinforcing bar, 20 feet length.'],
['name' => 'Rebar #5 (5/8" x 20 ft)', 'category' => 'Steel & Metal', 'unit' => 'Piece', 'unit_cost' => 9.50, 'description' => 'Standard #5 reinforcing bar.'],
['name' => 'Wire Mesh (6x6 W1.4/W1.4) 150ft Roll', 'category' => 'Steel & Metal', 'unit' => 'Roll', 'unit_cost' => 125.00, 'description' => 'Welded wire mesh for concrete slabs.'],
['name' => 'Structural Steel Beam (W8x10)', 'category' => 'Steel & Metal', 'unit' => 'Foot', 'unit_cost' => 15.00, 'description' => 'W8x10 wide flange steel beam.'],
['name' => 'Tie Wire (Black Annealed) 16 Gauge', 'category' => 'Steel & Metal', 'unit' => 'Roll (3 lb)', 'unit_cost' => 8.00, 'description' => 'Tie wire for rebar.'],
// Timber & Wood
['name' => '2x4 Framing Lumber (8 ft)', 'category' => 'Timber & Wood', 'unit' => 'Piece', 'unit_cost' => 3.50, 'description' => 'Standard SPF 2x4 framing stud.'],
['name' => '2x6 Framing Lumber (10 ft)', 'category' => 'Timber & Wood', 'unit' => 'Piece', 'unit_cost' => 6.00, 'description' => 'Standard 2x6 timber.'],
['name' => 'Plywood (CDX) 15/32" (4x8 ft)', 'category' => 'Timber & Wood', 'unit' => 'Sheet', 'unit_cost' => 22.00, 'description' => 'CDX structural plywood panel.'],
['name' => 'OSB Sheathing 7/16" (4x8 ft)', 'category' => 'Timber & Wood', 'unit' => 'Sheet', 'unit_cost' => 14.50, 'description' => 'Oriented strand board.'],
['name' => 'Treated Timber 4x4 (8 ft)', 'category' => 'Timber & Wood', 'unit' => 'Piece', 'unit_cost' => 11.20, 'description' => 'Pressure treated 4x4 post.'],
// Masonry & Bricks
['name' => 'Red Clay Brick', 'category' => 'Masonry', 'unit' => 'Thousand', 'unit_cost' => 450.00, 'description' => 'Standard solid red clay brick.'],
['name' => 'Mortar Mix (Type S)', 'category' => 'Masonry', 'unit' => 'Bag (80 lb)', 'unit_cost' => 9.00, 'description' => 'High strength masonry mortar.'],
['name' => 'Grout Mix (Non-Shrink)', 'category' => 'Masonry', 'unit' => 'Bag (50 lb)', 'unit_cost' => 14.00, 'description' => 'Structural non-shrink grout.'],
// Roofing
['name' => 'Asphalt Shingles (Architectural)', 'category' => 'Roofing', 'unit' => 'Bundle (33 sq ft)', 'unit_cost' => 35.00, 'description' => 'High quality architectural asphalt shingle.'],
['name' => 'Roofing Felt (15 lb, 400 sq ft)', 'category' => 'Roofing', 'unit' => 'Roll', 'unit_cost' => 20.00, 'description' => 'Asphalt saturated roofing felt base.'],
['name' => 'Corrugated Metal Roof Panel (12 ft)', 'category' => 'Roofing', 'unit' => 'Piece', 'unit_cost' => 28.00, 'description' => 'Galvanized iron corrugated sheet.'],
['name' => 'Roofing Nails (1-1/4", 50 lb)', 'category' => 'Roofing', 'unit' => 'Box', 'unit_cost' => 45.00, 'description' => 'Galvanized roofing nails.'],
// Insulation & Drywall
['name' => 'Fiberglass Insulation (R-13) 15" x 32\'', 'category' => 'Insulation', 'unit' => 'Roll', 'unit_cost' => 22.00, 'description' => 'Unfaced fiberglass insulation batt.'],
['name' => 'Rigid Foam Insulation 1" (4x8 ft)', 'category' => 'Insulation', 'unit' => 'Sheet', 'unit_cost' => 16.50, 'description' => 'Extruded polystyrene (XPS) rigid foam.'],
['name' => 'Drywall (Gypsum Board) 1/2" (4x8 ft)', 'category' => 'Drywall', 'unit' => 'Sheet', 'unit_cost' => 13.00, 'description' => 'Standard interior drywall.'],
['name' => 'Joint Compound (All-Purpose) 4.5 Gal', 'category' => 'Drywall', 'unit' => 'Bucket', 'unit_cost' => 16.00, 'description' => 'Ready-mixed joint compound.'],
['name' => 'Drywall Screws (1-1/4", 5 lb)', 'category' => 'Drywall', 'unit' => 'Box', 'unit_cost' => 18.00, 'description' => 'Coarse thread phosphate drywall screws.'],
// Plumbing & Piping
['name' => 'PVC Pipe SCH 40 (2" x 10 ft)', 'category' => 'Plumbing', 'unit' => 'Piece', 'unit_cost' => 15.00, 'description' => 'Schedule 40 PVC pipe.'],
['name' => 'PVC Pipe SCH 40 (4" x 10 ft)', 'category' => 'Plumbing', 'unit' => 'Piece', 'unit_cost' => 26.00, 'description' => 'Schedule 40 PVC pipe for drainage.'],
['name' => 'Copper Pipe Type L (1/2" x 10 ft)', 'category' => 'Plumbing', 'unit' => 'Piece', 'unit_cost' => 24.00, 'description' => 'Standard soft/hard copper piping.'],
['name' => 'PVC Cement & Primer Pack', 'category' => 'Plumbing', 'unit' => 'Pack', 'unit_cost' => 12.00, 'description' => 'Clear PVC cement and purple primer.'],
// Electrical
['name' => 'NM-B Wire 12/2 (250 ft Roll)', 'category' => 'Electrical', 'unit' => 'Roll', 'unit_cost' => 85.00, 'description' => 'Romex 12/2 residential wire w/ ground.'],
['name' => 'THHN Wire 10 AWG (500 ft Spool)', 'category' => 'Electrical', 'unit' => 'Spool', 'unit_cost' => 115.00, 'description' => 'Stranded copper building wire.'],
['name' => 'Electrical Box (1-Gang, 18 cu in)', 'category' => 'Electrical', 'unit' => 'Piece', 'unit_cost' => 0.85, 'description' => 'Nail-on PVC electrical box.'],
['name' => 'Conduit PVC SCH 40 (3/4" x 10 ft)', 'category' => 'Electrical', 'unit' => 'Piece', 'unit_cost' => 3.50, 'description' => 'Electrical PVC conduit.'],
// Paint & Finishes
['name' => 'Latex Primer (Interior) 5 Gal', 'category' => 'Paint', 'unit' => 'Bucket', 'unit_cost' => 55.00, 'description' => 'White interior latex drywall primer.'],
['name' => 'Interior Flat Paint (White) 5 Gal', 'category' => 'Paint', 'unit' => 'Bucket', 'unit_cost' => 70.00, 'description' => 'Professional grade flat white.'],
['name' => 'Exterior Semi-Gloss Paint 5 Gal', 'category' => 'Paint', 'unit' => 'Bucket', 'unit_cost' => 95.00, 'description' => 'Durable exterior grade semi-gloss paint.'],
// Consumables & Tools
['name' => 'Construction Adhesive (10 oz)', 'category' => 'Consumables', 'unit' => 'Tube', 'unit_cost' => 4.50, 'description' => 'Heavy duty polyurethane adhesive.'],
['name' => 'Painter\'s Tape (1.88" x 60 yds)', 'category' => 'Consumables', 'unit' => 'Roll', 'unit_cost' => 6.00, 'description' => 'Blue masking tape.'],
['name' => 'Work Gloves (Leather Palm)', 'category' => 'PPE', 'unit' => 'Pair', 'unit_cost' => 3.00, 'description' => 'Standard heavy-duty work gloves.'],
['name' => 'Safety Glasses', 'category' => 'PPE', 'unit' => 'Piece', 'unit_cost' => 4.00, 'description' => 'Clear polycarbonate safety glasses.'],
];
foreach ($materials as $materialData) {
$baseSku = strtoupper(substr($materialData['category'], 0, 3)) . '-' . rand(1000, 9999);
// Ensure unique sku
while(Material::where('sku', $baseSku)->exists()) {
$baseSku = strtoupper(substr($materialData['category'], 0, 3)) . '-' . rand(1000, 9999);
}
Material::firstOrCreate(
['name' => $materialData['name']],
[
'sku' => $baseSku,
'category' => $materialData['category'],
'unit' => $materialData['unit'],
'unit_cost' => $materialData['unit_cost'],
'description' => $materialData['description'],
'type' => 'single',
'status' => 'active'
]
);
}
// Seed Assemblies & Kits
$kitsAndAssemblies = [
[
'name' => 'Concrete Slab Pouring Kit',
'category' => 'Concrete & Cement',
'type' => 'kit',
'unit' => 'kit',
'description' => 'A complete pre-packaged materials kit for standard concrete slab pouring projects.',
'components' => [
'Portland Cement Type I' => 10.0,
'River Sand' => 2.0,
'Crushed Stone (Gravel) 3/4"' => 3.0,
'Wire Mesh (6x6 W1.4/W1.4) 150ft Roll' => 1.0,
'Tie Wire (Black Annealed) 16 Gauge' => 1.0,
]
],
[
'name' => 'Standard Interior Partition Assembly',
'category' => 'Drywall',
'type' => 'assembly',
'unit' => 'assembly',
'description' => 'A standard assembly representing materials for a 10-linear-foot interior drywall stud wall.',
'components' => [
'2x4 Framing Lumber (8 ft)' => 12.0,
'Drywall (Gypsum Board) 1/2" (4x8 ft)' => 8.0,
'Drywall Screws (1-1/4", 5 lb)' => 1.0,
'Joint Compound (All-Purpose) 4.5 Gal' => 0.5,
'Construction Adhesive (10 oz)' => 2.0,
]
],
[
'name' => 'Basic Residential Electrical Conduit Kit',
'category' => 'Electrical',
'type' => 'kit',
'unit' => 'kit',
'description' => 'Standard wiring, boxes, and conduit kit for a single-room electrical rough-in.',
'components' => [
'NM-B Wire 12/2 (250 ft Roll)' => 2.0,
'THHN Wire 10 AWG (500 ft Spool)' => 1.0,
'Electrical Box (1-Gang, 18 cu in)' => 15.0,
'Conduit PVC SCH 40 (3/4" x 10 ft)' => 12.0,
]
],
[
'name' => 'Standard Plumbing Drainage Assembly',
'category' => 'Plumbing',
'type' => 'assembly',
'unit' => 'assembly',
'description' => 'Standard PVC piping and connection adhesive assembly for bathroom drainage plumbing.',
'components' => [
'PVC Pipe SCH 40 (2" x 10 ft)' => 6.0,
'PVC Pipe SCH 40 (4" x 10 ft)' => 4.0,
'PVC Cement & Primer Pack' => 1.0,
]
],
[
'name' => 'Architectural Shingle Roofing Assembly',
'category' => 'Roofing',
'type' => 'assembly',
'unit' => 'assembly',
'description' => 'A roofing materials assembly covering approximately 100 square feet (1 square).',
'components' => [
'Asphalt Shingles (Architectural)' => 3.0,
'Roofing Felt (15 lb, 400 sq ft)' => 0.25,
'Roofing Nails (1-1/4", 50 lb)' => 0.1,
]
],
[
'name' => 'Interior Painting Finishing Kit',
'category' => 'Paint',
'type' => 'kit',
'unit' => 'kit',
'description' => 'A curated starter kit containing primer, flat paint, masking tape, and basic PPE.',
'components' => [
'Latex Primer (Interior) 5 Gal' => 1.0,
'Interior Flat Paint (White) 5 Gal' => 2.0,
'Painter\'s Tape (1.88" x 60 yds)' => 4.0,
'Work Gloves (Leather Palm)' => 2.0,
'Safety Glasses' => 2.0,
]
]
];
foreach ($kitsAndAssemblies as $kitData) {
$componentsToSave = [];
$calculatedUnitCost = 0;
foreach ($kitData['components'] as $name => $quantity) {
$componentMaterial = Material::where('name', $name)->first();
if ($componentMaterial) {
$componentsToSave[] = [
'component_id' => $componentMaterial->id,
'quantity' => $quantity
];
$calculatedUnitCost += ($componentMaterial->unit_cost * $quantity);
}
}
// Generate unique SKU
$baseSku = strtoupper(substr($kitData['category'], 0, 3)) . '-' . rand(1000, 9999);
while(Material::where('sku', $baseSku)->exists()) {
$baseSku = strtoupper(substr($kitData['category'], 0, 3)) . '-' . rand(1000, 9999);
}
$parentMaterial = Material::firstOrCreate(
['name' => $kitData['name']],
[
'sku' => $baseSku,
'category' => $kitData['category'],
'unit' => $kitData['unit'],
'unit_cost' => $calculatedUnitCost,
'description' => $kitData['description'],
'type' => $kitData['type'],
'status' => 'active'
]
);
// Sync or firstOrCreate components
foreach ($componentsToSave as $comp) {
MaterialComponent::firstOrCreate([
'parent_id' => $parentMaterial->id,
'component_id' => $comp['component_id'],
], [
'quantity' => $comp['quantity']
]);
}
}
}
}