Skip to content

A free open source IT asset/license management system

Depreciations factory

snipeecfe1a5442b5
diff --git a/database/factories/DepreciationFactory.php b/database/factories/DepreciationFactory.php
new file mode 100644
index 0000000000..e1df63dab2
--- /dev/null
+++ b/database/factories/DepreciationFactory.php
@@ -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,
+ ];
+});
+
+
+
+
diff --git a/database/seeds/DepreciationSeeder.php b/database/seeds/DepreciationSeeder.php
index 1ba63d54c3..4cf6055e6f 100644
--- a/database/seeds/DepreciationSeeder.php
+++ b/database/seeds/DepreciationSeeder.php
@@ -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
}
}