You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB
PHTML

2 years ago
<?php
namespace Database\Seeders;
2 years ago
use App\Models\Category;
use App\Models\Customer;
use App\Models\Product;
2 years ago
use Illuminate\Database\Seeder;
2 years ago
use Illuminate\Support\Str;
2 years ago
class DummySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
foreach (['makanan', 'minuman'] as $cat) {
2 years ago
$category = Category::create(['name' => $cat]);
}
$products = [
'Roti Tawar',
'Indomie',
2 years ago
'Telur Omega 3',
'Enervonche',
'Teh Olong',
'Teh Celup',
'Bakpi',
'Multivitamin',
'Kopi Kapal Api',
'White Kopi',
'Coklat',
'Perment',
'Galon',
'Sabun',
'Jam',
'Minyak Goreng',
'Tissue',
'Tissue Basah',
'Sandal',
'Payung',
'Handwash',
'Beras',
'Kaos',
'Sepatu',
'Obat Nyamuk'
];
foreach ($products as $prod) {
2 years ago
Product::create([
2 years ago
'code' => Str::upper(Str::random(6)),
2 years ago
'name' => $prod,
'price' => rand(1000, 10000),
'cost' => rand(1000, 10000),
'stock' => rand(1, 99),
2 years ago
'category_id' => $category->id,
]);
}
foreach (['Customer A', 'Customer B'] as $cust) {
Customer::create([
2 years ago
'code' => Str::upper(Str::random(6)),
2 years ago
'name' => $cust,
]);
}
2 years ago
}
}