mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Components factory and seeder
This commit is contained in:
parent
05c4d6dead
commit
ea6140e786
64
database/factories/ComponentsFactory.php
Normal file
64
database/factories/ComponentsFactory.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Components Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating components ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Component::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
|
||||
'purchase_cost' => $faker->randomFloat(2, 1, 50),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ram-crucial4', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
|
||||
'category_id' => 13,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ram-crucial8', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial 8GB DDR3L-1600 SODIMM Memory for Mac',
|
||||
'category_id' => 13,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ssd-crucial120', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial BX300 120GB SATA Internal SSD',
|
||||
'category_id' => 12,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ssd-crucial240', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial BX300 240GB SATA Internal SSD',
|
||||
'category_id' => 12,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,9 @@ class ComponentSeeder extends Seeder
|
|||
{
|
||||
Component::truncate();
|
||||
DB::table('components_assets')->truncate();
|
||||
factory(Component::class, 10)->create();
|
||||
factory(Component::class, 1)->states('ram-crucial4')->create(); // 1
|
||||
factory(Component::class, 1)->states('ram-crucial8')->create(); // 1
|
||||
factory(Component::class, 1)->states('ssd-crucial120')->create(); // 1
|
||||
factory(Component::class, 1)->states('ssd-crucial240')->create(); // 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue