Siopas Inventory PETI for ISTW Website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.4 KiB

<?php
namespace Database\Seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class PetiSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run()
{
// Generate 5 dummy data
for ($i = 0; $i < 5; $i++) {
DB::table('petis')->insert([
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Dummy Warna ' . ($i + 1),
'fix_lot' => 'Dummy Fix Lot ' . ($i + 1),
'packing_no' => rand(1, 100),
'customer_id' => $this->getRandomId('customers'),
'jumlah' => rand(1, 10),
'date_pembuatan' => now(),
'warehouse_id' => $this->getRandomId('m_warehouses'),
'kondisipeti_id' => $this->getRandomId('kondisi_petis'),
'status' => 'AKTIF',
'created_at' => now(),
'updated_at' => now(),
'created_by' => 'Seeder',
'updated_by' => 'Seeder',
]);
}
}
/**
* Get a random ID from a specific table
*
* @param string $tableName
* @return string|null
*/
protected function getRandomId($table)
{
return DB::table($table)->inRandomOrder()->first()->id;
}
}