Depreciations factory

This commit is contained in:
snipe 2017-10-07 05:30:53 -07:00
parent e9c77198d7
commit ecfe1a5442
2 changed files with 44 additions and 1 deletions

View file

@ -0,0 +1,41 @@
<?php
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
$factory->define(App\Models\Depreciation::class, function (Faker\Generator $faker) {
return [
'user_id' => 1,
];
});
$factory->state(App\Models\Depreciation::class, 'computer', function ($faker) {
return [
'name' => 'Computer Depreciation',
'months' => 36,
];
});
$factory->state(App\Models\Depreciation::class, 'display', function ($faker) {
return [
'name' => 'Display Depreciation',
'months' => 12,
];
});
$factory->state(App\Models\Depreciation::class, 'mobile-phones', function ($faker) {
return [
'name' => 'Mobile Phone Depreciation',
'months' => 24,
];
});

View file

@ -7,6 +7,8 @@ class DepreciationSeeder extends Seeder
public function run()
{
Depreciation::truncate();
factory(Depreciation::class, 5)->create();
factory(Depreciation::class, 1)->states('computer')->create(); // 1
factory(Depreciation::class, 1)->states('display')->create(); // 2
factory(Depreciation::class, 1)->states('mobile-phones')->create(); // 3
}
}