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.
 
 
 
 
 
 

130 lines
4.7 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' => 'Warna',
// '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',
// ]);
// }
DB::table('petis')->insert([
[
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Warna',
'fix_lot' => 'Dummy Fix Lot 1',
'packing_no' => 1,
'customer_id' => $this->getRandomId('customers'),
'jumlah' => 1,
'date_pembuatan' => now(),
'warehouse_id' => 1,
'kondisipeti_id' => $this->getRandomId('kondisi_petis'),
'status' => 'AKTIF',
'created_at' => now(),
'updated_at' => now(),
'created_by' => 'Seeder',
'updated_by' => 'Seeder',
],
[
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Warna',
'fix_lot' => 'Dummy Fix Lot 2',
'packing_no' => 2,
'customer_id' => $this->getRandomId('customers'),
'jumlah' => 2,
'date_pembuatan' => now(),
'warehouse_id' => 2,
'kondisipeti_id' => $this->getRandomId('kondisi_petis'),
'status' => 'AKTIF',
'created_at' => now(),
'updated_at' => now(),
'created_by' => 'Seeder',
'updated_by' => 'Seeder',
],
[
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Warna',
'fix_lot' => 'Dummy Fix Lot 3',
'packing_no' => 3,
'customer_id' => $this->getRandomId('customers'),
'jumlah' => 3,
'date_pembuatan' => now(),
'warehouse_id' => 3,
'kondisipeti_id' => $this->getRandomId('kondisi_petis'),
'status' => 'AKTIF',
'created_at' => now(),
'updated_at' => now(),
'created_by' => 'Seeder',
'updated_by' => 'Seeder',
],
[
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Warna',
'fix_lot' => 'Dummy Fix Lot 4',
'packing_no' => 4,
'customer_id' => $this->getRandomId('customers'),
'jumlah' => 4,
'date_pembuatan' => now(),
'warehouse_id' => 4,
'kondisipeti_id' => $this->getRandomId('kondisi_petis'),
'status' => 'AKTIF',
'created_at' => now(),
'updated_at' => now(),
'created_by' => 'Seeder',
'updated_by' => 'Seeder',
],
[
'tipe_peti_id' => $this->getRandomId('type_petis'),
'warna' => 'Warna',
'fix_lot' => 'Dummy Fix Lot 5',
'packing_no' => 5,
'customer_id' => $this->getRandomId('customers'),
'jumlah' => 5,
'date_pembuatan' => now(),
'warehouse_id' => 1,
'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;
}
}