Initial Commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Brand;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ProductModel;
|
||||
use App\Models\ProductSubcategory;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$items = [
|
||||
[
|
||||
'product_category_id' => ProductCategory::where('name','=','Laptop')->first()->id,
|
||||
'product_subcategory_id' => ProductSubcategory::where('name','=','Server Rum')->first()->id,
|
||||
'brand_id' => Brand::where('name','=','Test Brand')->first()->id,
|
||||
'product_model_id' => ProductModel::where('name','=','Test Model')->first()->id,
|
||||
'name' => 'Test Product',
|
||||
'description' => "Test Description",
|
||||
'total' => 100,
|
||||
'barcode' => "Test.Product.0001",
|
||||
],
|
||||
[
|
||||
'product_category_id' => ProductCategory::where('name','=','Laptop')->first()->id,
|
||||
'brand_id' => Brand::where('name','=','Test Brand')->first()->id,
|
||||
'product_model_id' => ProductModel::where('name','=','Test Model')->first()->id,
|
||||
'name' => 'Test Product 2',
|
||||
'description' => "Test Description 2",
|
||||
'total' => 100,
|
||||
'barcode' => "Test.Product.0002",
|
||||
],
|
||||
];
|
||||
foreach ($items as $item) {
|
||||
Product::create($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user