Skip to content

A free open source IT asset/license management system

Shift to class based factories

Laravel Shift104b441e0dff
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index b32822cd82..c3679ae571 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Acceptable;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
@@ -16,6 +17,8 @@ use Watson\Validating\ValidatingTrait;
*/
class Accessory extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\AccessoryPresenter::class;
use CompanyableTrait;
use Loggable, Presentable;
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php
index b42cfb5a00..d94725dfb2 100755
--- a/app/Models/Actionlog.php
+++ b/app/Models/Actionlog.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Carbon;
@@ -16,6 +17,8 @@ use Illuminate\Support\Facades\Auth;
*/
class Actionlog extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\ActionlogPresenter::class;
use SoftDeletes;
use Presentable;
diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index f193798fee..f83b2e14f9 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Events\AssetCheckedOut;
use App\Events\CheckoutableCheckedOut;
use App\Exceptions\CheckoutNotAllowed;
@@ -26,6 +27,8 @@ use Watson\Validating\ValidatingTrait;
*/
class Asset extends Depreciable
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\AssetPresenter::class;
use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait, UniqueSerialTrait;
diff --git a/app/Models/AssetMaintenance.php b/app/Models/AssetMaintenance.php
index cd4bba1a28..bee38abb61 100644
--- a/app/Models/AssetMaintenance.php
+++ b/app/Models/AssetMaintenance.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Helpers\Helper;
use App\Models\Traits\Searchable;
use Illuminate\Database\Eloquent\Model;
@@ -15,6 +16,8 @@ use Watson\Validating\ValidatingTrait;
*/
class AssetMaintenance extends Model implements ICompanyableChild
{
+ use HasFactory;
+
use SoftDeletes;
use CompanyableChildTrait;
use ValidatingTrait;
diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php
index df0f7a4d68..2d48f491fe 100755
--- a/app/Models/AssetModel.php
+++ b/app/Models/AssetModel.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,6 +17,8 @@ use Watson\Validating\ValidatingTrait;
*/
class AssetModel extends SnipeModel
{
+ use HasFactory;
+
use SoftDeletes;
protected $presenter = \App\Presenters\AssetModelPresenter::class;
use Requestable, Presentable;
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 0bcd5fd100..9c51fc4be4 100755
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
@@ -19,6 +20,8 @@ use Watson\Validating\ValidatingTrait;
*/
class Category extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\CategoryPresenter::class;
use Presentable;
use SoftDeletes;
diff --git a/app/Models/Company.php b/app/Models/Company.php
index e09c8472c7..dae7bd28d2 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Auth;
@@ -16,6 +17,8 @@ use Watson\Validating\ValidatingTrait;
*/
final class Company extends SnipeModel
{
+ use HasFactory;
+
protected $table = 'companies';
// Declare the rules for the model validation
diff --git a/app/Models/Component.php b/app/Models/Component.php
index f0af84fe71..3c15d2dddb 100644
--- a/app/Models/Component.php
+++ b/app/Models/Component.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -14,6 +15,8 @@ use Watson\Validating\ValidatingTrait;
*/
class Component extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\ComponentPresenter::class;
use CompanyableTrait;
use Loggable, Presentable;
diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php
index 26a146149b..203a56e4b8 100644
--- a/app/Models/Consumable.php
+++ b/app/Models/Consumable.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Acceptable;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
@@ -11,6 +12,8 @@ use Watson\Validating\ValidatingTrait;
class Consumable extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\ConsumablePresenter::class;
use CompanyableTrait;
use Loggable, Presentable;
diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php
index 01c85ab2c0..d601bb4ef3 100644
--- a/app/Models/CustomField.php
+++ b/app/Models/CustomField.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use EasySlugger\Utf8Slugger;
use Illuminate\Database\Eloquent\Model;
@@ -11,6 +12,8 @@ use Watson\Validating\ValidatingTrait;
class CustomField extends Model
{
+ use HasFactory;
+
use ValidatingTrait,
UniqueUndeletedTrait;
diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php
index 83e91a4b31..dbfb685f8f 100644
--- a/app/Models/CustomFieldset.php
+++ b/app/Models/CustomFieldset.php
@@ -2,12 +2,15 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use Gate;
use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
class CustomFieldset extends Model
{
+ use HasFactory;
+
use ValidatingTrait;
protected $guarded = ['id'];
diff --git a/app/Models/Department.php b/app/Models/Department.php
index 56be77115d..7b2adeb471 100644
--- a/app/Models/Department.php
+++ b/app/Models/Department.php
@@ -2,12 +2,15 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable;
use Watson\Validating\ValidatingTrait;
class Department extends SnipeModel
{
+ use HasFactory;
+
/**
* Whether the model should inject it's identifier to the unique
* validation rules before attempting validation. If this property
diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php
index 281524943a..9734315f08 100755
--- a/app/Models/Depreciation.php
+++ b/app/Models/Depreciation.php
@@ -2,12 +2,15 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Watson\Validating\ValidatingTrait;
class Depreciation extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\DepreciationPresenter::class;
use Presentable;
// Declare the rules for the form validation
diff --git a/app/Models/Group.php b/app/Models/Group.php
index ab432d2dd9..5d9a01c31f 100755
--- a/app/Models/Group.php
+++ b/app/Models/Group.php
@@ -2,11 +2,14 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use Watson\Validating\ValidatingTrait;
class Group extends SnipeModel
{
+ use HasFactory;
+
protected $table = 'permission_groups';
public $rules = [
diff --git a/app/Models/License.php b/app/Models/License.php
index 3476a141ef..8c2bf2d02b 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Carbon\Carbon;
@@ -13,6 +14,8 @@ use Watson\Validating\ValidatingTrait;
class License extends Depreciable
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\LicensePresenter::class;
use SoftDeletes;
diff --git a/app/Models/Location.php b/app/Models/Location.php
index 080158a909..a18eedc239 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Asset;
use App\Models\SnipeModel;
@@ -16,6 +17,8 @@ use Watson\Validating\ValidatingTrait;
class Location extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\LocationPresenter::class;
use Presentable;
use SoftDeletes;
diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php
index 0bd16f5bb3..6a96e36788 100755
--- a/app/Models/Manufacturer.php
+++ b/app/Models/Manufacturer.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -10,6 +11,8 @@ use Watson\Validating\ValidatingTrait;
class Manufacturer extends SnipeModel
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\ManufacturerPresenter::class;
use Presentable;
use SoftDeletes;
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index 9179a73c00..1721b78f44 100755
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Collection;
@@ -15,6 +16,8 @@ use Watson\Validating\ValidatingTrait;
*/
class Setting extends Model
{
+ use HasFactory;
+
use Notifiable, ValidatingTrait;
/**
diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php
index 772e1ee92d..47e2ec2517 100755
--- a/app/Models/Statuslabel.php
+++ b/app/Models/Statuslabel.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -9,6 +10,8 @@ use Watson\Validating\ValidatingTrait;
class Statuslabel extends SnipeModel
{
+ use HasFactory;
+
use SoftDeletes;
use ValidatingTrait;
use UniqueUndeletedTrait;
diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php
index 8752126b8d..ad09721ce2 100755
--- a/app/Models/Supplier.php
+++ b/app/Models/Supplier.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -9,6 +10,8 @@ use Watson\Validating\ValidatingTrait;
class Supplier extends SnipeModel
{
+ use HasFactory;
+
use SoftDeletes;
protected $table = 'suppliers';
diff --git a/app/Models/User.php b/app/Models/User.php
index f7ec2509cb..b07f08c2d7 100755
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable;
use App\Presenters\Presentable;
@@ -21,6 +22,8 @@ use Watson\Validating\ValidatingTrait;
class User extends SnipeModel implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, HasLocalePreference
{
+ use HasFactory;
+
protected $presenter = \App\Presenters\UserPresenter::class;
use SoftDeletes, ValidatingTrait;
use Authenticatable, Authorizable, CanResetPassword, HasApiTokens;
diff --git a/database/factories/AccessoryFactory.php b/database/factories/AccessoryFactory.php
index d6b9f0dde0..224241da0c 100644
--- a/database/factories/AccessoryFactory.php
+++ b/database/factories/AccessoryFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,57 +12,85 @@
|
*/
-$factory->define(App\Models\Accessory::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'model_number' => $faker->numberBetween(1000000, 50000000),
- 'location_id' => rand(1, 5),
- ];
-});
+class AccessoryFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Accessory::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'model_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'location_id' => rand(1, 5),
+ ];
+ }
-$factory->state(App\Models\Accessory::class, 'apple-bt-keyboard', function ($faker) {
- return [
- 'name' => 'Bluetooth Keyboard',
- 'image' => 'bluetooth.jpg',
- 'category_id' => 8,
- 'manufacturer_id' => 1,
- 'qty' => 10,
- 'min_amt' => 2,
- 'supplier_id' => rand(1, 5),
- ];
-});
+ public function appleBtKeyboard()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Bluetooth Keyboard',
+ 'image' => 'bluetooth.jpg',
+ 'category_id' => 8,
+ 'manufacturer_id' => 1,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ 'supplier_id' => rand(1, 5),
+ ];
+ });
+ }
-$factory->state(App\Models\Accessory::class, 'apple-usb-keyboard', function ($faker) {
- return [
- 'name' => 'USB Keyboard',
- 'image' => 'usb-keyboard.jpg',
- 'category_id' => 8,
- 'manufacturer_id' => 1,
- 'qty' => 15,
- 'min_amt' => 2,
- 'supplier_id' => rand(1, 5),
- ];
-});
+ public function appleUsbKeyboard()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'USB Keyboard',
+ 'image' => 'usb-keyboard.jpg',
+ 'category_id' => 8,
+ 'manufacturer_id' => 1,
+ 'qty' => 15,
+ 'min_amt' => 2,
+ 'supplier_id' => rand(1, 5),
+ ];
+ });
+ }
-$factory->state(App\Models\Accessory::class, 'apple-mouse', function ($faker) {
- return [
- 'name' => 'Magic Mouse',
- 'image' => 'magic-mouse.jpg',
- 'category_id' => 9,
- 'manufacturer_id' => 1,
- 'qty' => 13,
- 'min_amt' => 2,
- 'supplier_id' => rand(1, 5),
- ];
-});
+ public function appleMouse()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Magic Mouse',
+ 'image' => 'magic-mouse.jpg',
+ 'category_id' => 9,
+ 'manufacturer_id' => 1,
+ 'qty' => 13,
+ 'min_amt' => 2,
+ 'supplier_id' => rand(1, 5),
+ ];
+ });
+ }
-$factory->state(App\Models\Accessory::class, 'microsoft-mouse', function ($faker) {
- return [
- 'name' => 'Sculpt Comfort Mouse',
- 'image' => 'comfort-mouse.jpg',
- 'category_id' => 9,
- 'manufacturer_id' => 2,
- 'qty' => 13,
- 'min_amt' => 2,
- ];
-});
+ public function microsoftMouse()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Sculpt Comfort Mouse',
+ 'image' => 'comfort-mouse.jpg',
+ 'category_id' => 9,
+ 'manufacturer_id' => 2,
+ 'qty' => 13,
+ 'min_amt' => 2,
+ ];
+ });
+ }
+}
diff --git a/database/factories/ActionLogFactory.php b/database/factories/ActionlogFactory.php
similarity index 79%
rename from database/factories/ActionLogFactory.php
rename to database/factories/ActionlogFactory.php
index 939415c76b..17966f55b1 100644
--- a/database/factories/ActionLogFactory.php
+++ b/database/factories/ActionlogFactory.php
@@ -1,19 +1,17 @@
<?php
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Company;
use App\Models\Location;
use App\Models\User;
-$factory->define(Actionlog::class, function (Faker\Generator $faker) {
- return [
- 'note' => 'Sample checkout from DB seeder!',
- ];
-});
$factory->defineAs(App\Models\Actionlog::class, 'asset-upload', function ($faker) {
- $asset = factory(App\Models\Asset::class)->create();
+ $asset = \App\Models\Asset::factory()->create();
return [
'item_type' => get_class($asset),
@@ -74,6 +72,7 @@ $factory->defineAs(Actionlog::class, 'asset-checkout-location', function (Faker\
});
// This doesn't work - we need to assign a seat
+
$factory->defineAs(Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
$target = Asset::inRandomOrder()->RTD()->first();
$item = License::inRandomOrder()->first();
@@ -109,10 +108,10 @@ $factory->defineAs(Actionlog::class, 'accessory-checkout', function (Faker\Gener
});
$factory->defineAs(Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
- $company = factory(App\Models\Company::class)->create();
- $user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
- $target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
- $item = factory(App\Models\Consumable::class)->create(['company_id' => $company->id]);
+ $company = \App\Models\Company::factory()->create();
+ $user = \App\Models\User::factory()->create(['company_id' => $company->id]);
+ $target = \App\Models\User::factory()->create(['company_id' => $company->id]);
+ $item = \App\Models\Consumable::factory()->create(['company_id' => $company->id]);
return [
'user_id' => $user->id,
@@ -128,10 +127,10 @@ $factory->defineAs(Actionlog::class, 'consumable-checkout', function (Faker\Gene
});
$factory->defineAs(Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
- $company = factory(App\Models\Company::class)->create();
- $user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
- $target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
- $item = factory(App\Models\Component::class)->create(['company_id' => $company->id]);
+ $company = \App\Models\Company::factory()->create();
+ $user = \App\Models\User::factory()->create(['company_id' => $company->id]);
+ $target = \App\Models\User::factory()->create(['company_id' => $company->id]);
+ $item = \App\Models\Component::factory()->create(['company_id' => $company->id]);
return [
'user_id' => $user->id,
@@ -145,3 +144,25 @@ $factory->defineAs(Actionlog::class, 'component-checkout', function (Faker\Gener
'company_id' => $company->id,
];
});
+
+class ActionlogFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = Actionlog::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'note' => 'Sample checkout from DB seeder!',
+ ];
+ }
+}
diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php
index 32f739e0ba..d4bae8f8c4 100644
--- a/database/factories/AssetFactory.php
+++ b/database/factories/AssetFactory.php
@@ -1,5 +1,8 @@
<?php
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
@@ -13,198 +16,296 @@ use App\Models\Category;
|
*/
-$factory->define(Asset::class, function (Faker\Generator $faker) {
- return [
- 'name' => null,
- 'rtd_location_id' => rand(1, 10),
- 'serial' => $faker->uuid,
- 'status_id' => 1,
- 'user_id' => 1,
- 'asset_tag' => $faker->unixTime('now'),
- 'notes' => 'Created by DB seeder',
- 'purchase_date' => $faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
- 'purchase_cost' => $faker->randomFloat(2, '299.99', '2999.99'),
- 'order_number' => $faker->numberBetween(1000000, 50000000),
- 'supplier_id' => 1,
- 'requestable' => $faker->boolean(),
- 'assigned_to' => null,
- 'assigned_type' => null,
- 'next_audit_date' => null,
- 'last_checkout' => null,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-mbp', function ($faker) {
- return [
- 'model_id' => 1,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-mbp-pending', function ($faker) {
- return [
- 'model_id' => 1,
- 'status_id' => 2,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-mbp-archived', function ($faker) {
- return [
- 'model_id' => 1,
- 'status_id' => 3,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-air', function ($faker) {
- return [
- 'model_id' => 2,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-surface', function ($faker) {
- return [
- 'model_id' => 3,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-xps', function ($faker) {
- return [
- 'model_id' => 4,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-spectre', function ($faker) {
- return [
- 'model_id' => 5,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-zenbook', function ($faker) {
- return [
- 'model_id' => 6,
- ];
-});
-
-$factory->state(Asset::class, 'laptop-yoga', function ($faker) {
- return [
- 'model_id' => 7,
- ];
-});
-
-$factory->state(Asset::class, 'desktop-macpro', function ($faker) {
- return [
- 'model_id' => 8,
- ];
-});
-
-$factory->state(Asset::class, 'desktop-lenovo-i5', function ($faker) {
- return [
- 'model_id' => 9,
- ];
-});
-
-$factory->state(Asset::class, 'desktop-optiplex', function ($faker) {
- return [
- 'model_id' => 10,
- ];
-});
-
-$factory->state(Asset::class, 'conf-polycom', function ($faker) {
- return [
- 'model_id' => 11,
- ];
-});
-
-$factory->state(Asset::class, 'conf-polycomcx', function ($faker) {
- return [
- 'model_id' => 12,
- ];
-});
-
-$factory->state(Asset::class, 'tablet-ipad', function ($faker) {
- return [
- 'model_id' => 13,
- ];
-});
-
-$factory->state(Asset::class, 'tablet-tab3', function ($faker) {
- return [
- 'model_id' => 14,
- ];
-});
-
-$factory->state(Asset::class, 'phone-iphone6s', function ($faker) {
- return [
- 'model_id' => 15,
- ];
-});
-
-$factory->state(Asset::class, 'phone-iphone7', function ($faker) {
- return [
- 'model_id' => 16,
- ];
-});
-
-$factory->state(Asset::class, 'ultrafine', function ($faker) {
- return [
- 'model_id' => 17,
- ];
-});
-
-$factory->state(Asset::class, 'ultrasharp', function ($faker) {
- return [
- 'model_id' => 18,
- ];
-});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// These are just for unit tests, not to generate data
-$factory->state(Asset::class, 'assigned-to-user', function ($faker) {
- return [
- 'model_id' => 1,
- 'assigned_to' => factory(App\Models\User::class)->create()->id,
- 'assigned_type' => App\Models\User::class,
- ];
-});
-$factory->state(Asset::class, 'assigned-to-location', function ($faker) {
- return [
- 'model_id' => 1,
- 'assigned_to' => factory(App\Models\Location::class)->create()->id,
- 'assigned_type' => App\Models\Location::class,
- ];
-});
-$factory->state(Asset::class, 'assigned-to-asset', function ($faker) {
- return [
- 'model_id' => 1,
- 'assigned_to' => factory(App\Models\Asset::class)->create()->id,
- 'assigned_type' => App\Models\Asset::class,
- ];
-});
-
-$factory->state(Asset::class, 'requires-acceptance', function ($faker) {
- return [
- 'model_id' => 1,
- ];
-});
-
-$factory->state(Asset::class, 'deleted', function ($faker) {
- return [
- 'model_id' => 1,
- 'deleted_at' => $faker->dateTime(),
- ];
-});
-
-$factory->define(App\Models\AssetMaintenance::class, function (Faker\Generator $faker) {
- return [
- 'asset_id' => function () {
- return factory(App\Models\Asset::class)->create()->id;
- },
- 'supplier_id' => function () {
- return factory(App\Models\Supplier::class)->create()->id;
- },
- 'asset_maintenance_type' => $faker->randomElement(['maintenance', 'repair', 'upgrade']),
- 'title' => $faker->sentence,
- 'start_date' => $faker->date(),
- 'is_warranty' => $faker->boolean(),
- 'notes' => $faker->paragraph(),
- ];
-});
+class AssetFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = Asset::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => null,
+ 'rtd_location_id' => rand(1, 10),
+ 'serial' => $this->faker->uuid,
+ 'status_id' => 1,
+ 'user_id' => 1,
+ 'asset_tag' => $this->faker->unixTime('now'),
+ 'notes' => 'Created by DB seeder',
+ 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
+ 'purchase_cost' => $this->faker->randomFloat(2, '299.99', '2999.99'),
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'supplier_id' => 1,
+ 'requestable' => $this->faker->boolean(),
+ 'assigned_to' => null,
+ 'assigned_type' => null,
+ 'next_audit_date' => null,
+ 'last_checkout' => null,
+ ];
+ }
+
+ public function laptopMbp()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ ];
+ });
+ }
+
+ public function laptopMbpPending()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'status_id' => 2,
+ ];
+ });
+ }
+
+ public function laptopMbpArchived()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'status_id' => 3,
+ ];
+ });
+ }
+
+ public function laptopAir()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 2,
+ ];
+ });
+ }
+
+ public function laptopSurface()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 3,
+ ];
+ });
+ }
+
+ public function laptopXps()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 4,
+ ];
+ });
+ }
+
+ public function laptopSpectre()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 5,
+ ];
+ });
+ }
+
+ public function laptopZenbook()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 6,
+ ];
+ });
+ }
+
+ public function laptopYoga()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 7,
+ ];
+ });
+ }
+
+ public function desktopMacpro()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 8,
+ ];
+ });
+ }
+
+ public function desktopLenovoI5()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 9,
+ ];
+ });
+ }
+
+ public function desktopOptiplex()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 10,
+ ];
+ });
+ }
+
+ public function confPolycom()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 11,
+ ];
+ });
+ }
+
+ public function confPolycomcx()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 12,
+ ];
+ });
+ }
+
+ public function tabletIpad()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 13,
+ ];
+ });
+ }
+
+ public function tabletTab3()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 14,
+ ];
+ });
+ }
+
+ public function phoneIphone6s()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 15,
+ ];
+ });
+ }
+
+ public function phoneIphone7()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 16,
+ ];
+ });
+ }
+
+ public function ultrafine()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 17,
+ ];
+ });
+ }
+
+ public function ultrasharp()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 18,
+ ];
+ });
+ }
+
+ public function assignedToUser()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'assigned_to' => \App\Models\User::factory()->create()->id,
+ 'assigned_type' => App\Models\User::class,
+ ];
+ });
+ }
+
+ public function assignedToLocation()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'assigned_to' => \App\Models\Location::factory()->create()->id,
+ 'assigned_type' => App\Models\Location::class,
+ ];
+ });
+ }
+
+ public function assignedToAsset()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'assigned_to' => \App\Models\Asset::factory()->create()->id,
+ 'assigned_type' => App\Models\Asset::class,
+ ];
+ });
+ }
+
+ public function requiresAcceptance()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ ];
+ });
+ }
+
+ public function deleted()
+ {
+ return $this->state(function () {
+ return [
+ 'model_id' => 1,
+ 'deleted_at' => $this->faker->dateTime(),
+ ];
+ });
+ }
+}
diff --git a/database/factories/AssetMaintenanceFactory.php b/database/factories/AssetMaintenanceFactory.php
new file mode 100644
index 0000000000..b3793c822c
--- /dev/null
+++ b/database/factories/AssetMaintenanceFactory.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\Asset;
+use App\Models\AssetModel;
+use App\Models\Category;
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Factories related exclusively to modelling assets.
+|
+*/
+
+class AssetMaintenanceFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\AssetMaintenance::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'asset_id' => function () {
+ return \App\Models\Asset::factory()->create()->id;
+ },
+ 'supplier_id' => function () {
+ return \App\Models\Supplier::factory()->create()->id;
+ },
+ 'asset_maintenance_type' => $this->faker->randomElement(['maintenance', 'repair', 'upgrade']),
+ 'title' => $this->faker->sentence,
+ 'start_date' => $this->faker->date(),
+ 'is_warranty' => $this->faker->boolean(),
+ 'notes' => $this->faker->paragraph(),
+ ];
+ }
+}
diff --git a/database/factories/AssetModelFactory.php b/database/factories/AssetModelFactory.php
index 8b4e9ea105..38391b1712 100644
--- a/database/factories/AssetModelFactory.php
+++ b/database/factories/AssetModelFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -14,105 +17,20 @@
| Laptops
|--------------------------------------------------------------------------
*/
-$factory->define(App\Models\AssetModel::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'model_number' => $faker->creditCardNumber(),
- 'notes' => 'Created by demo seeder',
-
- ];
-});
// 1
-$factory->state(App\Models\AssetModel::class, 'mbp-13-model', function ($faker) {
- return [
- 'name' => 'Macbook Pro 13"',
- 'category_id' => 1,
- 'manufacturer_id' => 1,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'mbp.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 2
-$factory->state(App\Models\AssetModel::class, 'mbp-air-model', function ($faker) {
- return [
- 'name' => 'Macbook Air',
- 'category_id' => 1,
- 'manufacturer_id' => 1,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'macbookair.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 3
-$factory->state(App\Models\AssetModel::class, 'surface-model', function ($faker) {
- return [
- 'name' => 'Surface',
- 'category_id' => 1,
- 'manufacturer_id' => 2,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'surface.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 4
-$factory->state(App\Models\AssetModel::class, 'xps13-model', function ($faker) {
- return [
- 'name' => 'XPS 13',
- 'category_id' => 1,
- 'manufacturer_id' => 3,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'xps.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 5
-$factory->state(App\Models\AssetModel::class, 'zenbook-model', function ($faker) {
- return [
- 'name' => 'ZenBook UX310',
- 'category_id' => 1,
- 'manufacturer_id' => 4,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'zenbook.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 6
-$factory->state(App\Models\AssetModel::class, 'spectre-model', function ($faker) {
- return [
- 'name' => 'Spectre',
- 'category_id' => 1,
- 'manufacturer_id' => 5,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'spectre.jpg',
- 'fieldset_id' => 2,
- ];
-});
// 7
-$factory->state(App\Models\AssetModel::class, 'yoga-model', function ($faker) {
- return [
- 'name' => 'Yoga 910',
- 'category_id' => 1,
- 'manufacturer_id' => 6,
- 'eol' => '36',
- 'depreciation_id' => 1,
- 'image' => 'yoga.png',
- 'fieldset_id' => 2,
- ];
-});
/*
|--------------------------------------------------------------------------
@@ -120,42 +38,8 @@ $factory->state(App\Models\AssetModel::class, 'yoga-model', function ($faker) {
|--------------------------------------------------------------------------
*/
-$factory->state(App\Models\AssetModel::class, 'macpro-model', function ($faker) {
- return [
- 'name' => 'iMac Pro',
- 'category_id' => 2,
- 'manufacturer_id' => 1,
- 'eol' => '24',
- 'depreciation_id' => 1,
- 'image' => 'imacpro.jpg',
- 'fieldset_id' => 2,
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'lenovo-i5-model', function ($faker) {
- return [
- 'name' => 'Lenovo Intel Core i5',
- 'category_id' => 2,
- 'manufacturer_id' => 6,
- 'eol' => '24',
- 'depreciation_id' => 1,
- 'image' => 'lenovoi5.png',
- 'fieldset_id' => 2,
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'optiplex-model', function ($faker) {
- return [
- 'name' => 'OptiPlex',
- 'category_id' => 2,
- 'manufacturer_id' => 3,
- 'model_number' => '5040 (MRR81)',
- 'eol' => '24',
- 'depreciation_id' => 1,
- 'image' => 'optiplex.jpg',
- 'fieldset_id' => 2,
- ];
-});
+
+
/*
|--------------------------------------------------------------------------
@@ -163,27 +47,7 @@ $factory->state(App\Models\AssetModel::class, 'optiplex-model', function ($faker
|--------------------------------------------------------------------------
*/
-$factory->state(App\Models\AssetModel::class, 'polycom-model', function ($faker) {
- return [
- 'name' => 'SoundStation 2',
- 'category_id' => 6,
- 'manufacturer_id' => 8,
- 'eol' => '12',
- 'depreciation_id' => 1,
- 'image' => 'soundstation.jpg',
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'polycomcx-model', function ($faker) {
- return [
- 'name' => 'Polycom CX3000 IP Conference Phone',
- 'category_id' => 6,
- 'manufacturer_id' => 8,
- 'eol' => '12',
- 'depreciation_id' => 1,
- 'image' => 'cx3000.png',
- ];
-});
+
/*
|--------------------------------------------------------------------------
@@ -191,27 +55,7 @@ $factory->state(App\Models\AssetModel::class, 'polycomcx-model', function ($fake
|--------------------------------------------------------------------------
*/
-$factory->state(App\Models\AssetModel::class, 'ipad-model', function ($faker) {
- return [
- 'name' => 'iPad Pro',
- 'category_id' => 3,
- 'manufacturer_id' => 1,
- 'eol' => '12',
- 'depreciation_id' => 1,
- 'image' => 'ipad.jpg',
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'tab3-model', function ($faker) {
- return [
- 'name' => 'Tab3',
- 'category_id' => 3,
- 'manufacturer_id' => 6,
- 'eol' => '12',
- 'depreciation_id' => 1,
- 'image' => 'tab3.png',
- ];
-});
+
/*
|--------------------------------------------------------------------------
@@ -219,29 +63,7 @@ $factory->state(App\Models\AssetModel::class, 'tab3-model', function ($faker) {
|--------------------------------------------------------------------------
*/
-$factory->state(App\Models\AssetModel::class, 'iphone6s-model', function ($faker) {
- return [
- 'name' => 'iPhone 6s',
- 'category_id' => 4,
- 'manufacturer_id' => 1,
- 'eol' => '12',
- 'depreciation_id' => 3,
- 'image' => 'iphone6.jpg',
- 'fieldset_id' => 1,
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'iphone7-model', function ($faker) {
- return [
- 'name' => 'iPhone 7',
- 'category_id' => 4,
- 'manufacturer_id' => 1,
- 'eol' => '12',
- 'depreciation_id' => 1,
- 'image' => 'iphone7.jpg',
- 'fieldset_id' => 1,
- ];
-});
+
/*
|--------------------------------------------------------------------------
@@ -249,24 +71,292 @@ $factory->state(App\Models\AssetModel::class, 'iphone7-model', function ($faker)
|--------------------------------------------------------------------------
*/
-$factory->state(App\Models\AssetModel::class, 'ultrafine', function ($faker) {
- return [
- 'name' => 'Ultrafine 4k',
- 'category_id' => 5,
- 'manufacturer_id' => 7,
- 'eol' => '12',
- 'depreciation_id' => 2,
- 'image' => 'ultrafine.jpg',
- ];
-});
-
-$factory->state(App\Models\AssetModel::class, 'ultrasharp', function ($faker) {
- return [
- 'name' => 'Ultrasharp U2415',
- 'category_id' => 5,
- 'manufacturer_id' => 3,
- 'eol' => '12',
- 'depreciation_id' => 2,
- 'image' => 'ultrasharp.jpg',
- ];
-});
+class AssetModelFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\AssetModel::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'model_number' => $this->faker->creditCardNumber(),
+ 'notes' => 'Created by demo seeder',
+
+ ];
+ }
+
+ public function mbp13Model()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Macbook Pro 13"',
+ 'category_id' => 1,
+ 'manufacturer_id' => 1,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'mbp.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function mbpAirModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Macbook Air',
+ 'category_id' => 1,
+ 'manufacturer_id' => 1,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'macbookair.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function surfaceModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Surface',
+ 'category_id' => 1,
+ 'manufacturer_id' => 2,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'surface.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function xps13Model()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'XPS 13',
+ 'category_id' => 1,
+ 'manufacturer_id' => 3,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'xps.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function zenbookModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'ZenBook UX310',
+ 'category_id' => 1,
+ 'manufacturer_id' => 4,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'zenbook.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function spectreModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Spectre',
+ 'category_id' => 1,
+ 'manufacturer_id' => 5,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'spectre.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function yogaModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Yoga 910',
+ 'category_id' => 1,
+ 'manufacturer_id' => 6,
+ 'eol' => '36',
+ 'depreciation_id' => 1,
+ 'image' => 'yoga.png',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function macproModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'iMac Pro',
+ 'category_id' => 2,
+ 'manufacturer_id' => 1,
+ 'eol' => '24',
+ 'depreciation_id' => 1,
+ 'image' => 'imacpro.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function lenovoI5Model()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Lenovo Intel Core i5',
+ 'category_id' => 2,
+ 'manufacturer_id' => 6,
+ 'eol' => '24',
+ 'depreciation_id' => 1,
+ 'image' => 'lenovoi5.png',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function optiplexModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'OptiPlex',
+ 'category_id' => 2,
+ 'manufacturer_id' => 3,
+ 'model_number' => '5040 (MRR81)',
+ 'eol' => '24',
+ 'depreciation_id' => 1,
+ 'image' => 'optiplex.jpg',
+ 'fieldset_id' => 2,
+ ];
+ });
+ }
+
+ public function polycomModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'SoundStation 2',
+ 'category_id' => 6,
+ 'manufacturer_id' => 8,
+ 'eol' => '12',
+ 'depreciation_id' => 1,
+ 'image' => 'soundstation.jpg',
+ ];
+ });
+ }
+
+ public function polycomcxModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Polycom CX3000 IP Conference Phone',
+ 'category_id' => 6,
+ 'manufacturer_id' => 8,
+ 'eol' => '12',
+ 'depreciation_id' => 1,
+ 'image' => 'cx3000.png',
+ ];
+ });
+ }
+
+ public function ipadModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'iPad Pro',
+ 'category_id' => 3,
+ 'manufacturer_id' => 1,
+ 'eol' => '12',
+ 'depreciation_id' => 1,
+ 'image' => 'ipad.jpg',
+ ];
+ });
+ }
+
+ public function tab3Model()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Tab3',
+ 'category_id' => 3,
+ 'manufacturer_id' => 6,
+ 'eol' => '12',
+ 'depreciation_id' => 1,
+ 'image' => 'tab3.png',
+ ];
+ });
+ }
+
+ public function iphone6sModel()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'iPhone 6s',
+ 'category_id' => 4,
+ 'manufacturer_id' => 1,
+ 'eol' => '12',
+ 'depreciation_id' => 3,
+ 'image' => 'iphone6.jpg',
+ 'fieldset_id' => 1,
+ ];
+ });
+ }
+
+ public function iphone7Model()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'iPhone 7',
+ 'category_id' => 4,
+ 'manufacturer_id' => 1,
+ 'eol' => '12',
+ 'depreciation_id' => 1,
+ 'image' => 'iphone7.jpg',
+ 'fieldset_id' => 1,
+ ];
+ });
+ }
+
+ public function ultrafine()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Ultrafine 4k',
+ 'category_id' => 5,
+ 'manufacturer_id' => 7,
+ 'eol' => '12',
+ 'depreciation_id' => 2,
+ 'image' => 'ultrafine.jpg',
+ ];
+ });
+ }
+
+ public function ultrasharp()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Ultrasharp U2415',
+ 'category_id' => 5,
+ 'manufacturer_id' => 3,
+ 'eol' => '12',
+ 'depreciation_id' => 2,
+ 'image' => 'ultrasharp.jpg',
+ ];
+ });
+ }
+}
diff --git a/database/factories/CategoryFactory.php b/database/factories/CategoryFactory.php
index ec9a5f84f8..7ac5456bdc 100644
--- a/database/factories/CategoryFactory.php
+++ b/database/factories/CategoryFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,118 +12,179 @@
|
*/
-$factory->define(App\Models\Category::class, function (Faker\Generator $faker) {
- return [
- 'checkin_email' => $faker->boolean(),
- 'eula_text' => $faker->paragraph(),
- 'require_acceptance' => false,
- 'use_default_eula' => $faker->boolean(),
- 'user_id' => 1,
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-laptop-category', function ($faker) {
- return [
- 'name' => 'Laptops',
- 'category_type' => 'asset',
- 'require_acceptance' => true,
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-desktop-category', function ($faker) {
- return [
- 'name' => 'Desktops',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-display-category', function ($faker) {
- return [
- 'name' => 'Displays',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-tablet-category', function ($faker) {
- return [
- 'name' => 'Tablets',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-mobile-category', function ($faker) {
- return [
- 'name' => 'Mobile Phones',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-conference-category', function ($faker) {
- return [
- 'name' => 'Conference Phones',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'asset-voip-category', function ($faker) {
- return [
- 'name' => 'VOIP Phones',
- 'category_type' => 'asset',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'accessory-keyboard-category', function ($faker) {
- return [
- 'name' => 'Keyboards',
- 'category_type' => 'accessory',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'accessory-mouse-category', function ($faker) {
- return [
- 'name' => 'Mouse',
- 'category_type' => 'accessory',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'component-hdd-category', function ($faker) {
- return [
- 'name' => 'HDD/SSD',
- 'category_type' => 'component',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'component-ram-category', function ($faker) {
- return [
- 'name' => 'RAM',
- 'category_type' => 'component',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'consumable-paper-category', function ($faker) {
- return [
- 'name' => 'Printer Paper',
- 'category_type' => 'consumable',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'consumable-ink-category', function ($faker) {
- return [
- 'name' => 'Printer Ink',
- 'category_type' => 'consumable',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'license-graphics-category', function ($faker) {
- return [
- 'name' => 'Graphics Software',
- 'category_type' => 'license',
- ];
-});
-
-$factory->state(App\Models\Category::class, 'license-office-category', function ($faker) {
- return [
- 'name' => 'Office Software',
- 'category_type' => 'license',
- ];
-});
+class CategoryFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Category::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'checkin_email' => $this->faker->boolean(),
+ 'eula_text' => $this->faker->paragraph(),
+ 'require_acceptance' => false,
+ 'use_default_eula' => $this->faker->boolean(),
+ 'user_id' => 1,
+ ];
+ }
+
+ public function assetLaptopCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Laptops',
+ 'category_type' => 'asset',
+ 'require_acceptance' => true,
+ ];
+ });
+ }
+
+ public function assetDesktopCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Desktops',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function assetDisplayCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Displays',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function assetTabletCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Tablets',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function assetMobileCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Mobile Phones',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function assetConferenceCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Conference Phones',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function assetVoipCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'VOIP Phones',
+ 'category_type' => 'asset',
+ ];
+ });
+ }
+
+ public function accessoryKeyboardCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Keyboards',
+ 'category_type' => 'accessory',
+ ];
+ });
+ }
+
+ public function accessoryMouseCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Mouse',
+ 'category_type' => 'accessory',
+ ];
+ });
+ }
+
+ public function componentHddCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'HDD/SSD',
+ 'category_type' => 'component',
+ ];
+ });
+ }
+
+ public function componentRamCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'RAM',
+ 'category_type' => 'component',
+ ];
+ });
+ }
+
+ public function consumablePaperCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Printer Paper',
+ 'category_type' => 'consumable',
+ ];
+ });
+ }
+
+ public function consumableInkCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Printer Ink',
+ 'category_type' => 'consumable',
+ ];
+ });
+ }
+
+ public function licenseGraphicsCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Graphics Software',
+ 'category_type' => 'license',
+ ];
+ });
+ }
+
+ public function licenseOfficeCategory()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Office Software',
+ 'category_type' => 'license',
+ ];
+ });
+ }
+}
diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php
new file mode 100644
index 0000000000..9f1e0b4ac1
--- /dev/null
+++ b/database/factories/CompanyFactory.php
@@ -0,0 +1,45 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Here you may define all of your model factories. Model factories give
+| you a convenient way to create models for testing and seeding your
+| database. Just tell the factory how a default model should look.
+|
+*/
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\AssetModel;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\Location;
+use App\Models\Manufacturer;
+use App\Models\Statuslabel;
+use App\Models\Supplier;
+
+class CompanyFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Company::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->company,
+ ];
+ }
+}
diff --git a/database/factories/ComponentFactory.php b/database/factories/ComponentFactory.php
new file mode 100644
index 0000000000..10db6df97d
--- /dev/null
+++ b/database/factories/ComponentFactory.php
@@ -0,0 +1,115 @@
+<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+
+/*
+|--------------------------------------------------------------------------
+| Components Factories
+|--------------------------------------------------------------------------
+|
+| Factories related exclusively to creating components ..
+|
+*/
+
+class ComponentFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Component::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
+ 'purchase_cost' => $this->faker->randomFloat(2, 1, 50),
+ 'qty' => $this->faker->numberBetween(5, 10),
+ 'min_amt' => $this->faker->numberBetween($min = 1, $max = 2),
+ ];
+ }
+
+ public function ramCrucial4()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
+ 'category_id' => 13,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ 'location_id' => 3,
+ 'company_id' => 2,
+ ];
+ });
+ }
+
+ public function ramCrucial8()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Crucial 8GB DDR3L-1600 SODIMM Memory for Mac',
+ 'category_id' => 13,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ ];
+ });
+ }
+
+ public function ssdCrucial120()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Crucial BX300 120GB SATA Internal SSD',
+ 'category_id' => 12,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ ];
+ });
+ }
+
+ public function ssdCrucial240()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Crucial BX300 240GB SATA Internal SSD',
+ 'category_id' => 12,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ ];
+ });
+ }
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->text(20),
+ 'category_id' => function () {
+ return \App\Models\Category::factory()->create()->id;
+ },
+ 'location_id' => 1,
+ 'serial' => $this->faker->uuid,
+ 'qty' => $this->faker->numberBetween(3, 10),
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'purchase_date' => $this->faker->dateTime(),
+ 'purchase_cost' => $this->faker->randomFloat(2),
+ 'min_amt' => $this->faker->numberBetween($min = 1, $max = 2),
+ 'company_id' => function () {
+ return \App\Models\Company::factory()->create()->id;
+ },
+ ];
+ }
+}
diff --git a/database/factories/ComponentsFactory.php b/database/factories/ComponentsFactory.php
deleted file mode 100644
index 90c61d7bd6..0000000000
--- a/database/factories/ComponentsFactory.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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,
- 'location_id' => 3,
- 'company_id' => 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,
- ];
-});
diff --git a/database/factories/ConsumableFactory.php b/database/factories/ConsumableFactory.php
index 3148a0d7a4..9e88fb364c 100644
--- a/database/factories/ConsumableFactory.php
+++ b/database/factories/ConsumableFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,45 +12,70 @@
|
*/
-$factory->define(App\Models\Consumable::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'item_no' => $faker->numberBetween(1000000, 50000000),
- '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),
- ];
-});
+class ConsumableFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Consumable::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'item_no' => $this->faker->numberBetween(1000000, 50000000),
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
+ 'purchase_cost' => $this->faker->randomFloat(2, 1, 50),
+ 'qty' => $this->faker->numberBetween(5, 10),
+ 'min_amt' => $this->faker->numberBetween($min = 1, $max = 2),
+ ];
+ }
-$factory->state(App\Models\Consumable::class, 'cardstock', function ($faker) {
- return [
- 'name' => 'Cardstock (White)',
- 'category_id' => 10,
- 'manufacturer_id' => 10,
- 'qty' => 10,
- 'min_amt' => 2,
- 'company_id' => 3,
- ];
-});
+ public function cardstock()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Cardstock (White)',
+ 'category_id' => 10,
+ 'manufacturer_id' => 10,
+ 'qty' => 10,
+ 'min_amt' => 2,
+ 'company_id' => 3,
+ ];
+ });
+ }
-$factory->state(App\Models\Consumable::class, 'paper', function ($faker) {
- return [
- 'name' => 'Laserjet Paper (Ream)',
- 'category_id' => 10,
- 'manufacturer_id' => 10,
- 'qty' => 20,
- 'min_amt' => 2,
- ];
-});
+ public function paper()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Laserjet Paper (Ream)',
+ 'category_id' => 10,
+ 'manufacturer_id' => 10,
+ 'qty' => 20,
+ 'min_amt' => 2,
+ ];
+ });
+ }
-$factory->state(App\Models\Consumable::class, 'ink', function ($faker) {
- return [
- 'name' => 'Laserjet Toner (black)',
- 'category_id' => 11,
- 'manufacturer_id' => 5,
- 'qty' => 20,
- 'min_amt' => 2,
- ];
-});
+ public function ink()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Laserjet Toner (black)',
+ 'category_id' => 11,
+ 'manufacturer_id' => 5,
+ 'qty' => 20,
+ 'min_amt' => 2,
+ ];
+ });
+ }
+}
diff --git a/database/factories/CustomFieldFactory.php b/database/factories/CustomFieldFactory.php
new file mode 100644
index 0000000000..cf8323e6ff
--- /dev/null
+++ b/database/factories/CustomFieldFactory.php
@@ -0,0 +1,78 @@
+<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class CustomFieldFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\CustomField::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->catchPhrase,
+ 'format' => '',
+ 'element' => 'text',
+ ];
+ }
+
+ public function imei()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'IMEI',
+ 'help_text' => 'The IMEI number for this device.',
+ 'format' => 'regex:/^[0-9]{15}$/',
+ ];
+ });
+ }
+
+ public function phone()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Phone Number',
+ 'help_text' => 'Enter the phone number for this device.',
+ ];
+ });
+ }
+
+ public function ram()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'RAM',
+ 'help_text' => 'The amount of RAM this device has.',
+ ];
+ });
+ }
+
+ public function cpu()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'CPU',
+ 'help_text' => 'The speed of the processor on this device.',
+ ];
+ });
+ }
+
+ public function macAddress()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'MAC Address',
+ 'format' => 'regex:/^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/',
+ ];
+ });
+ }
+}
diff --git a/database/factories/CustomFieldsFactory.php b/database/factories/CustomFieldsFactory.php
deleted file mode 100644
index fd623341e2..0000000000
--- a/database/factories/CustomFieldsFactory.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-$factory->define(App\Models\CustomField::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->catchPhrase,
- 'format' => '',
- 'element' => 'text',
- ];
-});
-
-$factory->state(App\Models\CustomField::class, 'imei', function ($faker) {
- return [
- 'name' => 'IMEI',
- 'help_text' => 'The IMEI number for this device.',
- 'format' => 'regex:/^[0-9]{15}$/',
- ];
-});
-
-$factory->state(App\Models\CustomField::class, 'phone', function ($faker) {
- return [
- 'name' => 'Phone Number',
- 'help_text' => 'Enter the phone number for this device.',
- ];
-});
-
-$factory->state(App\Models\CustomField::class, 'ram', function ($faker) {
- return [
- 'name' => 'RAM',
- 'help_text' => 'The amount of RAM this device has.',
- ];
-});
-
-$factory->state(App\Models\CustomField::class, 'cpu', function ($faker) {
- return [
- 'name' => 'CPU',
- 'help_text' => 'The speed of the processor on this device.',
- ];
-});
-
-$factory->state(App\Models\CustomField::class, 'mac-address', function ($faker) {
- return [
- 'name' => 'MAC Address',
- 'format' => 'regex:/^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/',
- ];
-});
diff --git a/database/factories/CustomFieldsetFactory.php b/database/factories/CustomFieldsetFactory.php
index 7a31378ac7..0ea0197a3a 100644
--- a/database/factories/CustomFieldsetFactory.php
+++ b/database/factories/CustomFieldsetFactory.php
@@ -1,19 +1,43 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
-$factory->define(App\Models\CustomFieldset::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->catchPhrase,
- ];
-});
+class CustomFieldsetFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\CustomFieldset::class;
-$factory->state(App\Models\CustomFieldset::class, 'mobile', function ($faker) {
- return [
- 'name' => 'Mobile Devices',
- ];
-});
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->catchPhrase,
+ ];
+ }
-$factory->state(App\Models\CustomFieldset::class, 'computer', function ($faker) {
- return [
- 'name' => 'Laptops and Desktops',
- ];
-});
+ public function mobile()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Mobile Devices',
+ ];
+ });
+ }
+
+ public function computer()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Laptops and Desktops',
+ ];
+ });
+ }
+}
diff --git a/database/factories/DepartmentFactory.php b/database/factories/DepartmentFactory.php
new file mode 100644
index 0000000000..1c419291a5
--- /dev/null
+++ b/database/factories/DepartmentFactory.php
@@ -0,0 +1,99 @@
+<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+
+/*
+|--------------------------------------------------------------------------
+| Asset Model Factories
+|--------------------------------------------------------------------------
+|
+| Factories related exclusively to creating models ..
+|
+*/
+
+class DepartmentFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Department::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'location_id' => rand(1, 5),
+ ];
+ }
+
+ public function hr()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Human Resources',
+ ];
+ });
+ }
+
+ public function engineering()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Engineering',
+ ];
+ });
+ }
+
+ public function marketing()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Marketing',
+ ];
+ });
+ }
+
+ public function client()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Client Services',
+ ];
+ });
+ }
+
+ public function design()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Graphic Design',
+ ];
+ });
+ }
+
+ public function product()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Product Management',
+ ];
+ });
+ }
+
+ public function silly()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Dept of Silly Walks',
+ ];
+ });
+ }
+}
diff --git a/database/factories/DepartmentsFactory.php b/database/factories/DepartmentsFactory.php
deleted file mode 100644
index 6a394e191c..0000000000
--- a/database/factories/DepartmentsFactory.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-/*
-|--------------------------------------------------------------------------
-| Asset Model Factories
-|--------------------------------------------------------------------------
-|
-| Factories related exclusively to creating models ..
-|
-*/
-
-$factory->define(App\Models\Department::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'location_id' => rand(1, 5),
- ];
-});
-
-$factory->state(App\Models\Department::class, 'hr', function ($faker) {
- return [
- 'name' => 'Human Resources',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'engineering', function ($faker) {
- return [
- 'name' => 'Engineering',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'marketing', function ($faker) {
- return [
- 'name' => 'Marketing',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'client', function ($faker) {
- return [
- 'name' => 'Client Services',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'design', function ($faker) {
- return [
- 'name' => 'Graphic Design',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'product', function ($faker) {
- return [
- 'name' => 'Product Management',
- ];
-});
-
-$factory->state(App\Models\Department::class, 'silly', function ($faker) {
- return [
- 'name' => 'Dept of Silly Walks',
- ];
-});
diff --git a/database/factories/DepreciationFactory.php b/database/factories/DepreciationFactory.php
index da7dfd29a3..425b600b66 100644
--- a/database/factories/DepreciationFactory.php
+++ b/database/factories/DepreciationFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,29 +12,54 @@
|
*/
-$factory->define(App\Models\Depreciation::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- ];
-});
+class DepreciationFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Depreciation::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ ];
+ }
-$factory->state(App\Models\Depreciation::class, 'computer', function ($faker) {
- return [
- 'name' => 'Computer Depreciation',
- 'months' => 36,
- ];
-});
+ public function computer()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Computer Depreciation',
+ 'months' => 36,
+ ];
+ });
+ }
-$factory->state(App\Models\Depreciation::class, 'display', function ($faker) {
- return [
- 'name' => 'Display Depreciation',
- 'months' => 12,
- ];
-});
+ public function display()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Display Depreciation',
+ 'months' => 12,
+ ];
+ });
+ }
-$factory->state(App\Models\Depreciation::class, 'mobile-phones', function ($faker) {
- return [
- 'name' => 'Mobile Phone Depreciation',
- 'months' => 24,
- ];
-});
+ public function mobilePhones()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Mobile Phone Depreciation',
+ 'months' => 24,
+ ];
+ });
+ }
+}
diff --git a/database/factories/GroupFactory.php b/database/factories/GroupFactory.php
new file mode 100644
index 0000000000..e0542ef098
--- /dev/null
+++ b/database/factories/GroupFactory.php
@@ -0,0 +1,45 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Here you may define all of your model factories. Model factories give
+| you a convenient way to create models for testing and seeding your
+| database. Just tell the factory how a default model should look.
+|
+*/
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\AssetModel;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\Location;
+use App\Models\Manufacturer;
+use App\Models\Statuslabel;
+use App\Models\Supplier;
+
+class GroupFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Group::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->name,
+ ];
+ }
+}
diff --git a/database/factories/LicenseFactory.php b/database/factories/LicenseFactory.php
index 70bfa42e4b..00f20f218b 100644
--- a/database/factories/LicenseFactory.php
+++ b/database/factories/LicenseFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,72 +12,105 @@
|
*/
-$factory->define(App\Models\License::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'license_name' => $faker->name,
- 'license_email' => $faker->safeEmail,
- 'serial' => $faker->uuid,
- 'notes' => 'Created by DB seeder',
- 'purchase_date' => $faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
- 'order_number' => $faker->numberBetween(1000000, 50000000),
- 'expiration_date' => $faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
- 'reassignable' => $faker->boolean(),
- 'termination_date' => $faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
- 'supplier_id' => $faker->numberBetween(1, 5),
- ];
-});
// 1
-$factory->state(App\Models\License::class, 'photoshop', function ($faker) {
- $data = [
- 'name' => 'Photoshop',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '299.99',
- 'seats' => 10,
- 'purchase_order' => '13503Q',
- 'maintained' => true,
- 'category_id' => 14,
- ];
-
- return $data;
-});
// 2
-$factory->state(App\Models\License::class, 'acrobat', function ($faker) {
- $data = [
- 'name' => 'Acrobat',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '29.99',
- 'seats' => 10,
- 'category_id' => 14,
- ];
-
- return $data;
-});
// 3
-$factory->state(App\Models\License::class, 'indesign', function ($faker) {
- $data = [
- 'name' => 'InDesign',
- 'manufacturer_id' => 9,
- 'purchase_cost' => '199.99',
- 'seats' => 10,
- 'category_id' => 14,
- ];
-
- return $data;
-});
// 4
-$factory->state(App\Models\License::class, 'office', function ($faker) {
- $data = [
- 'name' => 'Office',
- 'manufacturer_id' => 2,
- 'purchase_cost' => '49.99',
- 'seats' => 20,
- 'category_id' => 15,
- ];
-
- return $data;
-});
+
+class LicenseFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\License::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'license_name' => $this->faker->name,
+ 'license_email' => $this->faker->safeEmail,
+ 'serial' => $this->faker->uuid,
+ 'notes' => 'Created by DB seeder',
+ 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
+ 'order_number' => $this->faker->numberBetween(1000000, 50000000),
+ 'expiration_date' => $this->faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
+ 'reassignable' => $this->faker->boolean(),
+ 'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
+ 'supplier_id' => $this->faker->numberBetween(1, 5),
+ ];
+ }
+
+ public function photoshop()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Photoshop',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '299.99',
+ 'seats' => 10,
+ 'purchase_order' => '13503Q',
+ 'maintained' => true,
+ 'category_id' => 14,
+ ];
+
+ return $data;
+ });
+ }
+
+ public function acrobat()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Acrobat',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '29.99',
+ 'seats' => 10,
+ 'category_id' => 14,
+ ];
+
+ return $data;
+ });
+ }
+
+ public function indesign()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'InDesign',
+ 'manufacturer_id' => 9,
+ 'purchase_cost' => '199.99',
+ 'seats' => 10,
+ 'category_id' => 14,
+ ];
+
+ return $data;
+ });
+ }
+
+ public function office()
+ {
+ return $this->state(function () {
+ $data = [
+ 'name' => 'Office',
+ 'manufacturer_id' => 2,
+ 'purchase_cost' => '49.99',
+ 'seats' => 20,
+ 'category_id' => 15,
+ ];
+
+ return $data;
+ });
+ }
+}
diff --git a/database/factories/LocationFactory.php b/database/factories/LocationFactory.php
new file mode 100644
index 0000000000..9a8e2e5094
--- /dev/null
+++ b/database/factories/LocationFactory.php
@@ -0,0 +1,53 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Here you may define all of your model factories. Model factories give
+| you a convenient way to create models for testing and seeding your
+| database. Just tell the factory how a default model should look.
+|
+*/
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\AssetModel;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\Location;
+use App\Models\Manufacturer;
+use App\Models\Statuslabel;
+use App\Models\Supplier;
+
+class LocationFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Location::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->city,
+ 'address' => $this->faker->streetAddress,
+ 'address2' => $this->faker->secondaryAddress,
+ 'city' => $this->faker->city,
+ 'state' => $this->faker->stateAbbr,
+ 'country' => $this->faker->countryCode,
+ 'currency' => $this->faker->currencyCode,
+ 'zip' => $this->faker->postcode,
+ 'image' => rand(1, 9).'.jpg',
+ ];
+ }
+}
diff --git a/database/factories/ManufacturerFactory.php b/database/factories/ManufacturerFactory.php
index a4ba86c19f..002d7f8088 100644
--- a/database/factories/ManufacturerFactory.php
+++ b/database/factories/ManufacturerFactory.php
@@ -1,4 +1,7 @@
<?php
+namespace Database\Factories;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
/*
|--------------------------------------------------------------------------
@@ -9,121 +12,182 @@
|
*/
-$factory->define(App\Models\Manufacturer::class, function (Faker\Generator $faker) {
- return [
- 'user_id' => 1,
- 'support_phone' => $faker->phoneNumber(),
- 'url' => $faker->url(),
- 'support_email' => $faker->safeEmail(),
- ];
-});
// 1
-$factory->state(App\Models\Manufacturer::class, 'apple', function ($faker) {
- return [
- 'name' => 'Apple',
- 'url' => 'https://apple.com',
- 'support_url' => 'https://support.apple.com',
- 'image' => 'apple.jpg',
- ];
-});
// 2
-$factory->state(App\Models\Manufacturer::class, 'microsoft', function ($faker) {
- return [
- 'name' => 'Microsoft',
- 'url' => 'https://microsoft.com',
- 'support_url' => 'https://support.microsoft.com',
- 'image' => 'microsoft.png',
- ];
-});
// 3
-$factory->state(App\Models\Manufacturer::class, 'dell', function ($faker) {
- return [
- 'name' => 'Dell',
- 'url' => 'https://dell.com',
- 'support_url' => 'https://support.dell.com',
- 'image' => 'dell.png',
- ];
-});
// 4
-$factory->state(App\Models\Manufacturer::class, 'asus', function ($faker) {
- return [
- 'name' => 'Asus',
- 'url' => 'https://asus.com',
- 'support_url' => 'https://support.asus.com',
- 'image' => 'asus.png',
- ];
-});
// 5
-$factory->state(App\Models\Manufacturer::class, 'hp', function ($faker) {
- return [
- 'name' => 'HP',
- 'url' => 'https://hp.com',
- 'support_url' => 'https://support.hp.com',
- 'image' => 'hp.png',
- ];
-});
// 6
-$factory->state(App\Models\Manufacturer::class, 'lenovo', function ($faker) {
- return [
- 'name' => 'Lenovo',
- 'url' => 'https://lenovo.com',
- 'support_url' => 'https://support.lenovo.com',
- 'image' => 'lenovo.jpg',
- ];
-});
// 7
-$factory->state(App\Models\Manufacturer::class, 'lg', function ($faker) {
- return [
- 'name' => 'LG',
- 'url' => 'https://lg.com',
- 'support_url' => 'https://support.lg.com',
- 'image' => 'lg.jpg',
- ];
-});
// 8
-$factory->state(App\Models\Manufacturer::class, 'polycom', function ($faker) {
- return [
- 'name' => 'Polycom',
- 'url' => 'https://polycom.com',
- 'support_url' => 'https://support.polycom.com',
- 'image' => 'polycom.png',
- ];
-});
// 9
-$factory->state(App\Models\Manufacturer::class, 'adobe', function ($faker) {
- return [
- 'name' => 'Adobe',
- 'url' => 'https://adobe.com',
- 'support_url' => 'https://support.adobe.com',
- 'image' => 'adobe.jpg',
- ];
-});
// 10
-$factory->state(App\Models\Manufacturer::class, 'avery', function ($faker) {
- return [
- 'name' => 'Avery',
- 'url' => 'https://avery.com',
- 'support_url' => 'https://support.avery.com',
- 'image' => 'avery.png',
- ];
-});
// 11
-$factory->state(App\Models\Manufacturer::class, 'crucial', function ($faker) {
- return [
- 'name' => 'Crucial',
- 'url' => 'https://crucial.com',
- 'support_url' => 'https://support.crucial.com',
- 'image' => 'crucial.jpg',
- ];
-});
+
+class ManufacturerFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Manufacturer::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'support_phone' => $this->faker->phoneNumber(),
+ 'url' => $this->faker->url(),
+ 'support_email' => $this->faker->safeEmail(),
+ ];
+ }
+
+ public function apple()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Apple',
+ 'url' => 'https://apple.com',
+ 'support_url' => 'https://support.apple.com',
+ 'image' => 'apple.jpg',
+ ];
+ });
+ }
+
+ public function microsoft()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Microsoft',
+ 'url' => 'https://microsoft.com',
+ 'support_url' => 'https://support.microsoft.com',
+ 'image' => 'microsoft.png',
+ ];
+ });
+ }
+
+ public function dell()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Dell',
+ 'url' => 'https://dell.com',
+ 'support_url' => 'https://support.dell.com',
+ 'image' => 'dell.png',
+ ];
+ });
+ }
+
+ public function asus()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Asus',
+ 'url' => 'https://asus.com',
+ 'support_url' => 'https://support.asus.com',
+ 'image' => 'asus.png',
+ ];
+ });
+ }
+
+ public function hp()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'HP',
+ 'url' => 'https://hp.com',
+ 'support_url' => 'https://support.hp.com',
+ 'image' => 'hp.png',
+ ];
+ });
+ }
+
+ public function lenovo()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Lenovo',
+ 'url' => 'https://lenovo.com',
+ 'support_url' => 'https://support.lenovo.com',
+ 'image' => 'lenovo.jpg',
+ ];
+ });
+ }
+
+ public function lg()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'LG',
+ 'url' => 'https://lg.com',
+ 'support_url' => 'https://support.lg.com',
+ 'image' => 'lg.jpg',
+ ];
+ });
+ }
+
+ public function polycom()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Polycom',
+ 'url' => 'https://polycom.com',
+ 'support_url' => 'https://support.polycom.com',
+ 'image' => 'polycom.png',
+ ];
+ });
+ }
+
+ public function adobe()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Adobe',
+ 'url' => 'https://adobe.com',
+ 'support_url' => 'https://support.adobe.com',
+ 'image' => 'adobe.jpg',
+ ];
+ });
+ }
+
+ public function avery()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Avery',
+ 'url' => 'https://avery.com',
+ 'support_url' => 'https://support.avery.com',
+ 'image' => 'avery.png',
+ ];
+ });
+ }
+
+ public function crucial()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Crucial',
+ 'url' => 'https://crucial.com',
+ 'support_url' => 'https://support.crucial.com',
+ 'image' => 'crucial.jpg',
+ ];
+ });
+ }
+}
diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php
deleted file mode 100644
index 9dd9a14a8a..0000000000
--- a/database/factories/ModelFactory.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-/*
-|--------------------------------------------------------------------------
-| Model Factories
-|--------------------------------------------------------------------------
-|
-| Here you may define all of your model factories. Model factories give
-| you a convenient way to create models for testing and seeding your
-| database. Just tell the factory how a default model should look.
-|
-*/
-
-use App\Models\AssetModel;
-use App\Models\Category;
-use App\Models\Company;
-use App\Models\Location;
-use App\Models\Manufacturer;
-use App\Models\Statuslabel;
-use App\Models\Supplier;
-
-$factory->define(App\Models\Company::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->company,
- ];
-});
-
-$factory->define(App\Models\Component::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->text(20),
- 'category_id' => function () {
- return factory(App\Models\Category::class)->create()->id;
- },
- 'location_id' => 1,
- 'serial' => $faker->uuid,
- 'qty' => $faker->numberBetween(3, 10),
- 'order_number' => $faker->numberBetween(1000000, 50000000),
- 'purchase_date' => $faker->dateTime(),
- 'purchase_cost' => $faker->randomFloat(2),
- 'min_amt' => $faker->numberBetween($min = 1, $max = 2),
- 'company_id' => function () {
- return factory(App\Models\Company::class)->create()->id;
- },
- ];
-});
-
-$factory->define(App\Models\Group::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->name,
- ];
-});
-
-$factory->define(App\Models\Location::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->city,
- 'address' => $faker->streetAddress,
- 'address2' => $faker->secondaryAddress,
- 'city' => $faker->city,
- 'state' => $faker->stateAbbr,
- 'country' => $faker->countryCode,
- 'currency' => $faker->currencyCode,
- 'zip' => $faker->postcode,
- 'image' => rand(1, 9).'.jpg',
- ];
-});
-
-$factory->define(App\Models\Supplier::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->company,
- 'address' => $faker->streetAddress,
- 'address2' => $faker->secondaryAddress,
- 'city' => $faker->city,
- 'state' => $faker->stateAbbr,
- 'zip' => $faker->postCode,
- 'country' => $faker->countryCode,
- 'contact' => $faker->name,
- 'phone' => $faker->phoneNumber,
- 'fax' => $faker->phoneNumber,
- 'email' => $faker->safeEmail,
- 'url' => $faker->url,
- 'notes' => $faker->text(191), // Supplier notes can be a max of 255 characters.
- ];
-});
-
-$factory->define(App\Models\Setting::class, function ($faker) {
- return [
- 'user_id' => 1,
- 'per_page' => 20,
- 'site_name' => $faker->sentence,
- 'auto_increment_assets' => false,
- 'alert_email' => $faker->safeEmail(),
- 'alerts_enabled' => true,
- 'brand' => 1,
- 'default_currency' => $faker->currencyCode,
- 'locale' => $faker->locale,
- 'pwd_secure_min' => 10, // Match web setup
- 'email_domain' => 'test.com',
- ];
-});
diff --git a/database/factories/SettingFactory.php b/database/factories/SettingFactory.php
new file mode 100644
index 0000000000..530c35b060
--- /dev/null
+++ b/database/factories/SettingFactory.php
@@ -0,0 +1,55 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Here you may define all of your model factories. Model factories give
+| you a convenient way to create models for testing and seeding your
+| database. Just tell the factory how a default model should look.
+|
+*/
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\AssetModel;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\Location;
+use App\Models\Manufacturer;
+use App\Models\Statuslabel;
+use App\Models\Supplier;
+
+class SettingFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Setting::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'user_id' => 1,
+ 'per_page' => 20,
+ 'site_name' => $this->faker->sentence,
+ 'auto_increment_assets' => false,
+ 'alert_email' => $this->faker->safeEmail(),
+ 'alerts_enabled' => true,
+ 'brand' => 1,
+ 'default_currency' => $this->faker->currencyCode,
+ 'locale' => $this->faker->locale,
+ 'pwd_secure_min' => 10, // Match web setup
+ 'email_domain' => 'test.com',
+ ];
+ }
+}
diff --git a/database/factories/StatusLabelFactory.php b/database/factories/StatusLabelFactory.php
deleted file mode 100644
index 1c850564d8..0000000000
--- a/database/factories/StatusLabelFactory.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-use App\Models\Statuslabel;
-
-$factory->define(Statuslabel::class, function (Faker\Generator $faker) {
- return [
- 'name' => $faker->sentence,
- 'created_at' => $faker->dateTime(),
- 'updated_at' => $faker->dateTime(),
- 'user_id' => 1,
- 'deleted_at' => null,
- 'deployable' => 0,
- 'pending' => 0,
- 'archived' => 0,
- 'notes' => '',
- ];
-});
-$factory->state(Statuslabel::class, 'rtd', function (Faker\Generator $faker) {
- return [
- 'notes' => $faker->sentence,
- 'deployable' => 1,
- 'default_label' => 1,
- ];
-});
-$factory->state(Statuslabel::class, 'pending', function (Faker\Generator $faker) {
- return [
- 'notes' => $faker->sentence,
- 'pending' => 1,
- 'default_label' => 1,
- ];
-});
-
-$factory->state(Statuslabel::class, 'archived', function (Faker\Generator $faker) {
- return [
- 'notes' => 'These assets are permanently undeployable',
- 'archived' => 1,
- 'default_label' => 0,
- ];
-});
-
-$factory->state(Statuslabel::class, 'out_for_diagnostics', function (Faker\Generator $faker) {
- return [
- 'name' => 'Out for Diagnostics',
- 'default_label' => 0,
- ];
-});
-
-$factory->state(Statuslabel::class, 'out_for_repair', function (Faker\Generator $faker) {
- return [
- 'name' => 'Out for Repair',
- 'default_label' => 0,
- ];
-});
-
-$factory->state(Statuslabel::class, 'broken', function (Faker\Generator $faker) {
- return [
- 'name' => 'Broken - Not Fixable',
- 'default_label' => 0,
- ];
-});
-
-$factory->state(Statuslabel::class, 'lost', function (Faker\Generator $faker) {
- return [
- 'name' => 'Lost/Stolen',
- 'default_label' => 0,
- ];
-});
diff --git a/database/factories/StatuslabelFactory.php b/database/factories/StatuslabelFactory.php
new file mode 100644
index 0000000000..1bb67684ce
--- /dev/null
+++ b/database/factories/StatuslabelFactory.php
@@ -0,0 +1,109 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\Statuslabel;
+
+class StatuslabelFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = Statuslabel::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->sentence,
+ 'created_at' => $this->faker->dateTime(),
+ 'updated_at' => $this->faker->dateTime(),
+ 'user_id' => 1,
+ 'deleted_at' => null,
+ 'deployable' => 0,
+ 'pending' => 0,
+ 'archived' => 0,
+ 'notes' => '',
+ ];
+ }
+
+ public function rtd()
+ {
+ return $this->state(function () {
+ return [
+ 'notes' => $this->faker->sentence,
+ 'deployable' => 1,
+ 'default_label' => 1,
+ ];
+ });
+ }
+
+ public function pending()
+ {
+ return $this->state(function () {
+ return [
+ 'notes' => $this->faker->sentence,
+ 'pending' => 1,
+ 'default_label' => 1,
+ ];
+ });
+ }
+
+ public function archived()
+ {
+ return $this->state(function () {
+ return [
+ 'notes' => 'These assets are permanently undeployable',
+ 'archived' => 1,
+ 'default_label' => 0,
+ ];
+ });
+ }
+
+ public function outForDiagnostics()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Out for Diagnostics',
+ 'default_label' => 0,
+ ];
+ });
+ }
+
+ public function outForRepair()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Out for Repair',
+ 'default_label' => 0,
+ ];
+ });
+ }
+
+ public function broken()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Broken - Not Fixable',
+ 'default_label' => 0,
+ ];
+ });
+ }
+
+ public function lost()
+ {
+ return $this->state(function () {
+ return [
+ 'name' => 'Lost/Stolen',
+ 'default_label' => 0,
+ ];
+ });
+ }
+}
diff --git a/database/factories/SupplierFactory.php b/database/factories/SupplierFactory.php
new file mode 100644
index 0000000000..dd4a58616b
--- /dev/null
+++ b/database/factories/SupplierFactory.php
@@ -0,0 +1,57 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Model Factories
+|--------------------------------------------------------------------------
+|
+| Here you may define all of your model factories. Model factories give
+| you a convenient way to create models for testing and seeding your
+| database. Just tell the factory how a default model should look.
+|
+*/
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use App\Models\AssetModel;
+use App\Models\Category;
+use App\Models\Company;
+use App\Models\Location;
+use App\Models\Manufacturer;
+use App\Models\Statuslabel;
+use App\Models\Supplier;
+
+class SupplierFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\Supplier::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'name' => $this->faker->company,
+ 'address' => $this->faker->streetAddress,
+ 'address2' => $this->faker->secondaryAddress,
+ 'city' => $this->faker->city,
+ 'state' => $this->faker->stateAbbr,
+ 'zip' => $this->faker->postCode,
+ 'country' => $this->faker->countryCode,
+ 'contact' => $this->faker->name,
+ 'phone' => $this->faker->phoneNumber,
+ 'fax' => $this->faker->phoneNumber,
+ 'email' => $this->faker->safeEmail,
+ 'url' => $this->faker->url,
+ 'notes' => $this->faker->text(191), // Supplier notes can be a max of 255 characters.
+ ];
+ }
+}
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index cf5a0688d0..3efbaa8f33 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -1,278 +1,451 @@
<?php
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Company;
$password = bcrypt('password');
-$factory->define(App\Models\User::class, function (Faker\Generator $faker) use ($password) {
- return [
- 'activated' => 1,
- 'address' => $faker->address,
- 'city' => $faker->city,
- 'company_id' => rand(1, 4),
- 'country' => $faker->country,
- 'department_id' => rand(1, 6),
- 'email' => $faker->safeEmail,
- 'employee_num' => $faker->numberBetween(3500, 35050),
- 'first_name' => $faker->firstName,
- 'jobtitle' => $faker->jobTitle,
- 'last_name' => $faker->lastName,
- 'locale' => $faker->locale,
- 'location_id' => rand(1, 5),
- 'notes' => 'Created by DB seeder',
- 'password' => $password,
- 'permissions' => '{"user":"0"}',
- 'phone' => $faker->phoneNumber,
- 'state' => $faker->stateAbbr,
- 'username' => $faker->username,
- 'zip' => $faker->postcode,
- ];
-});
-
-$factory->state(App\Models\User::class, 'first-admin', function ($faker) {
- return [
- 'first_name' => 'Admin',
- 'last_name' => 'User',
- 'username' => 'admin',
- 'permissions' => '{"superuser":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'snipe-admin', function ($faker) {
- return [
- 'first_name' => 'Snipe E.',
- 'last_name' => 'Head',
- 'username' => 'snipe',
- 'email' => '[email protected]',
- 'permissions' => '{"superuser":"1"}',
- ];
-});
+
+
// USER GLOBAL PERMISSION STATES
-$factory->state(App\Models\User::class, 'superuser', function ($faker) {
- return [
- 'permissions' => '{"superuser":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'admin', function ($faker) {
- return [
- 'permissions' => '{"admin":"1"}',
- 'manager_id' => rand(1, 2),
- ];
-});
+
// USER ASSET PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.delete":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkin-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.checkin":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkout-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.checkout":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'view-requestable-assets', function ($faker) {
- return [
- 'permissions' => '{"assets.view.requestable":"1"}',
- ];
-});
+
+
+
+
+
+
// USER ACCESSORY PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.delete":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkin-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.checkin":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkout-accessories', function ($faker) {
- return [
- 'permissions' => '{"accessories.checkout":"1"}',
- ];
-});
+
+
+
+
+
// USER CONSUMABLE PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.delete":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkin-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.checkin":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkout-consumables', function ($faker) {
- return [
- 'permissions' => '{"consumables.checkout":"1"}',
- ];
-});
+
+
+
+
+
// USER LICENSE PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.delete":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkout-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.checkout":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'view-keys-licenses', function ($faker) {
- return [
- 'permissions' => '{"licenses.keys":"1"}',
- ];
-});
+
+
+
+
+
// USER COMPONENTS PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-components', function ($faker) {
- return [
- 'permissions' => '{"components.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-components', function ($faker) {
- return [
- 'permissions' => '{"components.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-components', function ($faker) {
- return [
- 'permissions' => '{"components.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-components', function ($faker) {
- return [
- 'permissions' => '{"components.delete":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkin-components', function ($faker) {
- return [
- 'permissions' => '{"components.checkin":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'checkout-components', function ($faker) {
- return [
- 'permissions' => '{"components.checkout":"1"}',
- ];
-});
+
+
+
+
+
// USER USER PERMISSION STATES
-$factory->state(App\Models\User::class, 'view-users', function ($faker) {
- return [
- 'permissions' => '{"users.view":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'create-users', function ($faker) {
- return [
- 'permissions' => '{"users.create":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'edit-users', function ($faker) {
- return [
- 'permissions' => '{"users.edit":"1"}',
- ];
-});
-
-$factory->state(App\Models\User::class, 'delete-users', function ($faker) {
- return [
- 'permissions' => '{"users.delete":"1"}',
- ];
-});
+
+class UserFactory extends Factory
+{
+ /**
+ * The name of the factory's corresponding model.
+ *
+ * @var string
+ */
+ protected $model = \App\Models\User::class;
+
+ /**
+ * Define the model's default state.
+ *
+ * @return array
+ */
+ public function definition()
+ {
+ return [
+ 'activated' => 1,
+ 'address' => $this->faker->address,
+ 'city' => $this->faker->city,
+ 'company_id' => rand(1, 4),
+ 'country' => $this->faker->country,
+ 'department_id' => rand(1, 6),
+ 'email' => $this->faker->safeEmail,
+ 'employee_num' => $this->faker->numberBetween(3500, 35050),
+ 'first_name' => $this->faker->firstName,
+ 'jobtitle' => $this->faker->jobTitle,
+ 'last_name' => $this->faker->lastName,
+ 'locale' => $this->faker->locale,
+ 'location_id' => rand(1, 5),
+ 'notes' => 'Created by DB seeder',
+ 'password' => $password,
+ 'permissions' => '{"user":"0"}',
+ 'phone' => $this->faker->phoneNumber,
+ 'state' => $this->faker->stateAbbr,
+ 'username' => $this->faker->username,
+ 'zip' => $this->faker->postcode,
+ ];
+ }
+
+ public function firstAdmin()
+ {
+ return $this->state(function () {
+ return [
+ 'first_name' => 'Admin',
+ 'last_name' => 'User',
+ 'username' => 'admin',
+ 'permissions' => '{"superuser":"1"}',
+ ];
+ });
+ }
+
+ public function snipeAdmin()
+ {
+ return $this->state(function () {
+ return [
+ 'first_name' => 'Snipe E.',
+ 'last_name' => 'Head',
+ 'username' => 'snipe',
+ 'email' => '[email protected]',
+ 'permissions' => '{"superuser":"1"}',
+ ];
+ });
+ }
+
+ public function superuser()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"superuser":"1"}',
+ ];
+ });
+ }
+
+ public function admin()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"admin":"1"}',
+ 'manager_id' => rand(1, 2),
+ ];
+ });
+ }
+
+ public function viewAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.view":"1"}',
+ ];
+ });
+ }
+
+ public function createAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.create":"1"}',
+ ];
+ });
+ }
+
+ public function editAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.delete":"1"}',
+ ];
+ });
+ }
+
+ public function checkinAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.checkin":"1"}',
+ ];
+ });
+ }
+
+ public function checkoutAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.checkout":"1"}',
+ ];
+ });
+ }
+
+ public function viewRequestableAssets()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"assets.view.requestable":"1"}',
+ ];
+ });
+ }
+
+ public function viewAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.view":"1"}',
+ ];
+ });
+ }
+
+ public function createAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.create":"1"}',
+ ];
+ });
+ }
+
+ public function editAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.delete":"1"}',
+ ];
+ });
+ }
+
+ public function checkinAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.checkin":"1"}',
+ ];
+ });
+ }
+
+ public function checkoutAccessories()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"accessories.checkout":"1"}',
+ ];
+ });
+ }
+
+ public function viewConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.view":"1"}',
+ ];
+ });
+ }
+
+ public function createConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.create":"1"}',
+ ];
+ });
+ }
+
+ public function editConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.delete":"1"}',
+ ];
+ });
+ }
+
+ public function checkinConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.checkin":"1"}',
+ ];
+ });
+ }
+
+ public function checkoutConsumables()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"consumables.checkout":"1"}',
+ ];
+ });
+ }
+
+ public function viewLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.view":"1"}',
+ ];
+ });
+ }
+
+ public function createLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.create":"1"}',
+ ];
+ });
+ }
+
+ public function editLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.delete":"1"}',
+ ];
+ });
+ }
+
+ public function checkoutLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.checkout":"1"}',
+ ];
+ });
+ }
+
+ public function viewKeysLicenses()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"licenses.keys":"1"}',
+ ];
+ });
+ }
+
+ public function viewComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.view":"1"}',
+ ];
+ });
+ }
+
+ public function createComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.create":"1"}',
+ ];
+ });
+ }
+
+ public function editComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.delete":"1"}',
+ ];
+ });
+ }
+
+ public function checkinComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.checkin":"1"}',
+ ];
+ });
+ }
+
+ public function checkoutComponents()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"components.checkout":"1"}',
+ ];
+ });
+ }
+
+ public function viewUsers()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"users.view":"1"}',
+ ];
+ });
+ }
+
+ public function createUsers()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"users.create":"1"}',
+ ];
+ });
+ }
+
+ public function editUsers()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"users.edit":"1"}',
+ ];
+ });
+ }
+
+ public function deleteUsers()
+ {
+ return $this->state(function () {
+ return [
+ 'permissions' => '{"users.delete":"1"}',
+ ];
+ });
+ }
+}
diff --git a/database/seeds/AccessorySeeder.php b/database/seeds/AccessorySeeder.php
index 7f35ba8e0e..dc9a1704dd 100644
--- a/database/seeds/AccessorySeeder.php
+++ b/database/seeds/AccessorySeeder.php
@@ -9,10 +9,10 @@ class AccessorySeeder extends Seeder
{
Accessory::truncate();
DB::table('accessories_users')->truncate();
- factory(Accessory::class, 1)->states('apple-usb-keyboard')->create();
- factory(Accessory::class, 1)->states('apple-bt-keyboard')->create();
- factory(Accessory::class, 1)->states('apple-mouse')->create();
- factory(Accessory::class, 1)->states('microsoft-mouse')->create();
+ Accessory::factory()->count(1)->appleUsbKeyboard()->create();
+ Accessory::factory()->count(1)->appleBtKeyboard()->create();
+ Accessory::factory()->count(1)->appleMouse()->create();
+ Accessory::factory()->count(1)->microsoftMouse()->create();
$src = public_path('/img/demo/accessories/');
$dst = 'accessories'.'/';
diff --git a/database/seeds/ActionlogSeeder.php b/database/seeds/ActionlogSeeder.php
index 71d0bb08b8..9efb6c889e 100644
--- a/database/seeds/ActionlogSeeder.php
+++ b/database/seeds/ActionlogSeeder.php
@@ -8,7 +8,7 @@ class ActionlogSeeder extends Seeder
public function run()
{
Actionlog::truncate();
- factory(Actionlog::class, 'asset-checkout-user', 300)->create();
- factory(Actionlog::class, 'asset-checkout-location', 100)->create();
+ Actionlog::factory()->count('asset-checkout-user', 300)->create();
+ Actionlog::factory()->count('asset-checkout-location', 100)->create();
}
}
diff --git a/database/seeds/AssetModelSeeder.php b/database/seeds/AssetModelSeeder.php
index b179c5788e..5e143f2553 100755
--- a/database/seeds/AssetModelSeeder.php
+++ b/database/seeds/AssetModelSeeder.php
@@ -11,34 +11,34 @@ class AssetModelSeeder extends Seeder
AssetModel::truncate();
// Laptops
- factory(AssetModel::class, 1)->states('mbp-13-model')->create(); // 1
- factory(AssetModel::class, 1)->states('mbp-air-model')->create(); // 2
- factory(AssetModel::class, 1)->states('surface-model')->create(); // 3
- factory(AssetModel::class, 1)->states('xps13-model')->create(); // 4
- factory(AssetModel::class, 1)->states('spectre-model')->create(); // 5
- factory(AssetModel::class, 1)->states('zenbook-model')->create(); // 6
- factory(AssetModel::class, 1)->states('yoga-model')->create(); // 7
+ AssetModel::factory()->count(1)->mbp13Model()->create(); // 1
+ AssetModel::factory()->count(1)->mbpAirModel()->create(); // 2
+ AssetModel::factory()->count(1)->surfaceModel()->create(); // 3
+ AssetModel::factory()->count(1)->xps13Model()->create(); // 4
+ AssetModel::factory()->count(1)->spectreModel()->create(); // 5
+ AssetModel::factory()->count(1)->zenbookModel()->create(); // 6
+ AssetModel::factory()->count(1)->yogaModel()->create(); // 7
// Desktops
- factory(AssetModel::class, 1)->states('macpro-model')->create(); // 8
- factory(AssetModel::class, 1)->states('lenovo-i5-model')->create(); // 9
- factory(AssetModel::class, 1)->states('optiplex-model')->create(); // 10
+ AssetModel::factory()->count(1)->macproModel()->create(); // 8
+ AssetModel::factory()->count(1)->lenovoI5Model()->create(); // 9
+ AssetModel::factory()->count(1)->optiplexModel()->create(); // 10
// Conference Phones
- factory(AssetModel::class, 1)->states('polycom-model')->create(); // 11
- factory(AssetModel::class, 1)->states('polycomcx-model')->create(); // 12
+ AssetModel::factory()->count(1)->polycomModel()->create(); // 11
+ AssetModel::factory()->count(1)->polycomcxModel()->create(); // 12
// Tablets
- factory(AssetModel::class, 1)->states('ipad-model')->create(); // 13
- factory(AssetModel::class, 1)->states('tab3-model')->create(); // 14
+ AssetModel::factory()->count(1)->ipadModel()->create(); // 13
+ AssetModel::factory()->count(1)->tab3Model()->create(); // 14
// Phones
- factory(AssetModel::class, 1)->states('iphone6s-model')->create(); // 15
- factory(AssetModel::class, 1)->states('iphone7-model')->create(); // 16
+ AssetModel::factory()->count(1)->iphone6sModel()->create(); // 15
+ AssetModel::factory()->count(1)->iphone7Model()->create(); // 16
// Displays
- factory(AssetModel::class, 1)->states('ultrafine')->create(); // 17
- factory(AssetModel::class, 1)->states('ultrasharp')->create(); // 18
+ AssetModel::factory()->count(1)->ultrafine()->create(); // 17
+ AssetModel::factory()->count(1)->ultrasharp()->create(); // 18
$src = public_path('/img/demo/models/');
$dst = 'models'.'/';
diff --git a/database/seeds/AssetSeeder.php b/database/seeds/AssetSeeder.php
index 1d7db0f1a3..e5f4524472 100644
--- a/database/seeds/AssetSeeder.php
+++ b/database/seeds/AssetSeeder.php
@@ -9,31 +9,31 @@ class AssetSeeder extends Seeder
public function run()
{
Asset::truncate();
- factory(Asset::class, 1000)->states('laptop-mbp')->create();
- factory(Asset::class, 50)->states('laptop-mbp-pending')->create();
- factory(Asset::class, 50)->states('laptop-mbp-archived')->create();
- factory(Asset::class, 50)->states('laptop-air')->create();
- factory(Asset::class, 5)->states('laptop-surface')->create();
- factory(Asset::class, 5)->states('laptop-xps')->create();
- factory(Asset::class, 5)->states('laptop-spectre')->create();
- factory(Asset::class, 5)->states('laptop-zenbook')->create();
- factory(Asset::class, 3)->states('laptop-yoga')->create();
-
- factory(Asset::class, 30)->states('desktop-macpro')->create();
- factory(Asset::class, 30)->states('desktop-lenovo-i5')->create();
- factory(Asset::class, 30)->states('desktop-optiplex')->create();
-
- factory(Asset::class, 5)->states('conf-polycom')->create();
- factory(Asset::class, 2)->states('conf-polycomcx')->create();
-
- factory(Asset::class, 12)->states('tablet-ipad')->create();
- factory(Asset::class, 4)->states('tablet-tab3')->create();
-
- factory(Asset::class, 27)->states('phone-iphone6s')->create();
- factory(Asset::class, 40)->states('phone-iphone7')->create();
-
- factory(Asset::class, 10)->states('ultrafine')->create();
- factory(Asset::class, 10)->states('ultrasharp')->create();
+ Asset::factory()->count(1000)->laptopMbp()->create();
+ Asset::factory()->count(50)->laptopMbpPending()->create();
+ Asset::factory()->count(50)->laptopMbpArchived()->create();
+ Asset::factory()->count(50)->laptopAir()->create();
+ Asset::factory()->count(5)->laptopSurface()->create();
+ Asset::factory()->count(5)->laptopXps()->create();
+ Asset::factory()->count(5)->laptopSpectre()->create();
+ Asset::factory()->count(5)->laptopZenbook()->create();
+ Asset::factory()->count(3)->laptopYoga()->create();
+
+ Asset::factory()->count(30)->desktopMacpro()->create();
+ Asset::factory()->count(30)->desktopLenovoI5()->create();
+ Asset::factory()->count(30)->desktopOptiplex()->create();
+
+ Asset::factory()->count(5)->confPolycom()->create();
+ Asset::factory()->count(2)->confPolycomcx()->create();
+
+ Asset::factory()->count(12)->tabletIpad()->create();
+ Asset::factory()->count(4)->tabletTab3()->create();
+
+ Asset::factory()->count(27)->phoneIphone6s()->create();
+ Asset::factory()->count(40)->phoneIphone7()->create();
+
+ Asset::factory()->count(10)->ultrafine()->create();
+ Asset::factory()->count(10)->ultrasharp()->create();
$del_files = Storage::files('assets');
foreach ($del_files as $del_file) { // iterate files
diff --git a/database/seeds/CategorySeeder.php b/database/seeds/CategorySeeder.php
index 37e11a2be8..92f72371cf 100755
--- a/database/seeds/CategorySeeder.php
+++ b/database/seeds/CategorySeeder.php
@@ -9,20 +9,20 @@ class CategorySeeder extends Seeder
{
Category::truncate();
- factory(Category::class, 1)->states('asset-laptop-category')->create(); // 1
- factory(Category::class, 1)->states('asset-desktop-category')->create(); // 2
- factory(Category::class, 1)->states('asset-tablet-category')->create(); // 3
- factory(Category::class, 1)->states('asset-mobile-category')->create(); // 4
- factory(Category::class, 1)->states('asset-display-category')->create(); // 5
- factory(Category::class, 1)->states('asset-voip-category')->create(); // 6
- factory(Category::class, 1)->states('asset-conference-category')->create(); // 7
- factory(Category::class, 1)->states('accessory-keyboard-category')->create(); // 8
- factory(Category::class, 1)->states('accessory-mouse-category')->create(); // 9
- factory(Category::class, 1)->states('consumable-paper-category')->create(); // 10
- factory(Category::class, 1)->states('consumable-ink-category')->create(); // 11
- factory(Category::class, 1)->states('component-hdd-category')->create(); // 12
- factory(Category::class, 1)->states('component-ram-category')->create(); // 13
- factory(Category::class, 1)->states('license-graphics-category')->create(); // 14
- factory(Category::class, 1)->states('license-office-category')->create(); // 15
+ Category::factory()->count(1)->assetLaptopCategory()->create(); // 1
+ Category::factory()->count(1)->assetDesktopCategory()->create(); // 2
+ Category::factory()->count(1)->assetTabletCategory()->create(); // 3
+ Category::factory()->count(1)->assetMobileCategory()->create(); // 4
+ Category::factory()->count(1)->assetDisplayCategory()->create(); // 5
+ Category::factory()->count(1)->assetVoipCategory()->create(); // 6
+ Category::factory()->count(1)->assetConferenceCategory()->create(); // 7
+ Category::factory()->count(1)->accessoryKeyboardCategory()->create(); // 8
+ Category::factory()->count(1)->accessoryMouseCategory()->create(); // 9
+ Category::factory()->count(1)->consumablePaperCategory()->create(); // 10
+ Category::factory()->count(1)->consumableInkCategory()->create(); // 11
+ Category::factory()->count(1)->componentHddCategory()->create(); // 12
+ Category::factory()->count(1)->componentRamCategory()->create(); // 13
+ Category::factory()->count(1)->licenseGraphicsCategory()->create(); // 14
+ Category::factory()->count(1)->licenseOfficeCategory()->create(); // 15
}
}
diff --git a/database/seeds/CompanySeeder.php b/database/seeds/CompanySeeder.php
index 5969b8cdbb..181108dcd1 100644
--- a/database/seeds/CompanySeeder.php
+++ b/database/seeds/CompanySeeder.php
@@ -14,7 +14,7 @@ class CompanySeeder extends Seeder
{
\Log::debug('Seed companies');
Company::truncate();
- factory(Company::class, 4)->create();
+ Company::factory()->count(4)->create();
$src = public_path('/img/demo/companies/');
$dst = 'companies'.'/';
diff --git a/database/seeds/ComponentSeeder.php b/database/seeds/ComponentSeeder.php
index 1347901a21..109272aa64 100644
--- a/database/seeds/ComponentSeeder.php
+++ b/database/seeds/ComponentSeeder.php
@@ -9,9 +9,9 @@ class ComponentSeeder extends Seeder
{
Component::truncate();
DB::table('components_assets')->truncate();
- 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
+ Component::factory()->count(1)->ramCrucial4()->create(); // 1
+ Component::factory()->count(1)->ramCrucial8()->create(); // 1
+ Component::factory()->count(1)->ssdCrucial120()->create(); // 1
+ Component::factory()->count(1)->ssdCrucial240()->create(); // 1
}
}
diff --git a/database/seeds/ConsumableSeeder.php b/database/seeds/ConsumableSeeder.php
index 2c01b53b7f..72671a1fc1 100644
--- a/database/seeds/ConsumableSeeder.php
+++ b/database/seeds/ConsumableSeeder.php
@@ -9,8 +9,8 @@ class ConsumableSeeder extends Seeder
{
Consumable::truncate();
DB::table('consumables_users')->truncate();
- factory(Consumable::class, 1)->states('cardstock')->create(); // 1
- factory(Consumable::class, 1)->states('paper')->create(); // 2
- factory(Consumable::class, 1)->states('ink')->create(); // 3
+ Consumable::factory()->count(1)->cardstock()->create(); // 1
+ Consumable::factory()->count(1)->paper()->create(); // 2
+ Consumable::factory()->count(1)->ink()->create(); // 3
}
}
diff --git a/database/seeds/CustomFieldSeeder.php b/database/seeds/CustomFieldSeeder.php
index 0f8fb75399..75c7bff240 100644
--- a/database/seeds/CustomFieldSeeder.php
+++ b/database/seeds/CustomFieldSeeder.php
@@ -23,13 +23,13 @@ class CustomFieldSeeder extends Seeder
CustomFieldset::truncate();
DB::table('custom_field_custom_fieldset')->truncate();
- factory(CustomFieldset::class, 1)->states('mobile')->create();
- factory(CustomFieldset::class, 1)->states('computer')->create();
- factory(CustomField::class, 1)->states('imei')->create();
- factory(CustomField::class, 1)->states('phone')->create();
- factory(CustomField::class, 1)->states('ram')->create();
- factory(CustomField::class, 1)->states('cpu')->create();
- factory(CustomField::class, 1)->states('mac-address')->create();
+ CustomFieldset::factory()->count(1)->mobile()->create();
+ CustomFieldset::factory()->count(1)->computer()->create();
+ CustomField::factory()->count(1)->imei()->create();
+ CustomField::factory()->count(1)->phone()->create();
+ CustomField::factory()->count(1)->ram()->create();
+ CustomField::factory()->count(1)->cpu()->create();
+ CustomField::factory()->count(1)->macAddress()->create();
DB::table('custom_field_custom_fieldset')->insert([
[
diff --git a/database/seeds/DepartmentSeeder.php b/database/seeds/DepartmentSeeder.php
index 3b3f929c77..c4c28e0382 100644
--- a/database/seeds/DepartmentSeeder.php
+++ b/database/seeds/DepartmentSeeder.php
@@ -8,11 +8,11 @@ class DepartmentSeeder extends Seeder
public function run()
{
Department::truncate();
- factory(Department::class, 1)->states('hr')->create(); // 1
- factory(Department::class, 1)->states('engineering')->create(); // 2
- factory(Department::class, 1)->states('marketing')->create(); // 3
- factory(Department::class, 1)->states('client')->create(); // 4
- factory(Department::class, 1)->states('product')->create(); // 5
- factory(Department::class, 1)->states('silly')->create(); // 6
+ Department::factory()->count(1)->hr()->create(); // 1
+ Department::factory()->count(1)->engineering()->create(); // 2
+ Department::factory()->count(1)->marketing()->create(); // 3
+ Department::factory()->count(1)->client()->create(); // 4
+ Department::factory()->count(1)->product()->create(); // 5
+ Department::factory()->count(1)->silly()->create(); // 6
}
}
diff --git a/database/seeds/DepreciationSeeder.php b/database/seeds/DepreciationSeeder.php
index 17c5bb09f1..bc5612579b 100644
--- a/database/seeds/DepreciationSeeder.php
+++ b/database/seeds/DepreciationSeeder.php
@@ -8,8 +8,8 @@ class DepreciationSeeder extends Seeder
public function run()
{
Depreciation::truncate();
- 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
+ Depreciation::factory()->count(1)->computer()->create(); // 1
+ Depreciation::factory()->count(1)->display()->create(); // 2
+ Depreciation::factory()->count(1)->mobilePhones()->create(); // 3
}
}
diff --git a/database/seeds/LicenseSeeder.php b/database/seeds/LicenseSeeder.php
index 74e7193c4e..b32498312a 100644
--- a/database/seeds/LicenseSeeder.php
+++ b/database/seeds/LicenseSeeder.php
@@ -10,9 +10,9 @@ class LicenseSeeder extends Seeder
{
License::truncate();
LicenseSeat::truncate();
- factory(License::class, 1)->states('photoshop')->create();
- factory(License::class, 1)->states('acrobat')->create();
- factory(License::class, 1)->states('indesign')->create();
- factory(License::class, 1)->states('office')->create();
+ License::factory()->count(1)->photoshop()->create();
+ License::factory()->count(1)->acrobat()->create();
+ License::factory()->count(1)->indesign()->create();
+ License::factory()->count(1)->office()->create();
}
}
diff --git a/database/seeds/LocationSeeder.php b/database/seeds/LocationSeeder.php
index be7ea0fa18..82216fdb21 100644
--- a/database/seeds/LocationSeeder.php
+++ b/database/seeds/LocationSeeder.php
@@ -9,7 +9,7 @@ class LocationSeeder extends Seeder
public function run()
{
Location::truncate();
- factory(Location::class, 10)->create();
+ Location::factory()->count(10)->create();
$src = public_path('/img/demo/locations/');
$dst = 'locations'.'/';
diff --git a/database/seeds/ManufacturerSeeder.php b/database/seeds/ManufacturerSeeder.php
index c7bde59b0d..59685dc57b 100644
--- a/database/seeds/ManufacturerSeeder.php
+++ b/database/seeds/ManufacturerSeeder.php
@@ -9,17 +9,17 @@ class ManufacturerSeeder extends Seeder
public function run()
{
Manufacturer::truncate();
- factory(Manufacturer::class, 1)->states('apple')->create(); // 1
- factory(Manufacturer::class, 1)->states('microsoft')->create(); // 2
- factory(Manufacturer::class, 1)->states('dell')->create(); // 3
- factory(Manufacturer::class, 1)->states('asus')->create(); // 4
- factory(Manufacturer::class, 1)->states('hp')->create(); // 5
- factory(Manufacturer::class, 1)->states('lenovo')->create(); // 6
- factory(Manufacturer::class, 1)->states('lg')->create(); // 7
- factory(Manufacturer::class, 1)->states('polycom')->create(); // 8
- factory(Manufacturer::class, 1)->states('adobe')->create(); // 9
- factory(Manufacturer::class, 1)->states('avery')->create(); // 10
- factory(Manufacturer::class, 1)->states('crucial')->create(); // 10
+ Manufacturer::factory()->count(1)->apple()->create(); // 1
+ Manufacturer::factory()->count(1)->microsoft()->create(); // 2
+ Manufacturer::factory()->count(1)->dell()->create(); // 3
+ Manufacturer::factory()->count(1)->asus()->create(); // 4
+ Manufacturer::factory()->count(1)->hp()->create(); // 5
+ Manufacturer::factory()->count(1)->lenovo()->create(); // 6
+ Manufacturer::factory()->count(1)->lg()->create(); // 7
+ Manufacturer::factory()->count(1)->polycom()->create(); // 8
+ Manufacturer::factory()->count(1)->adobe()->create(); // 9
+ Manufacturer::factory()->count(1)->avery()->create(); // 10
+ Manufacturer::factory()->count(1)->crucial()->create(); // 10
$src = public_path('/img/demo/manufacturers/');
$dst = 'manufacturers'.'/';
diff --git a/database/seeds/StatuslabelSeeder.php b/database/seeds/StatuslabelSeeder.php
index 733ed33d12..558aa92f5b 100755
--- a/database/seeds/StatuslabelSeeder.php
+++ b/database/seeds/StatuslabelSeeder.php
@@ -8,12 +8,12 @@ class StatuslabelSeeder extends Seeder
public function run()
{
Statuslabel::truncate();
- factory(Statuslabel::class)->states('rtd')->create(['name' => 'Ready to Deploy']);
- factory(Statuslabel::class)->states('pending')->create(['name' => 'Pending']);
- factory(Statuslabel::class)->states('archived')->create(['name' => 'Archived']);
- factory(Statuslabel::class)->states('out_for_diagnostics')->create();
- factory(Statuslabel::class)->states('out_for_repair')->create();
- factory(Statuslabel::class)->states('broken')->create();
- factory(Statuslabel::class)->states('lost')->create();
+ Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
+ Statuslabel::factory()->pending()->create(['name' => 'Pending']);
+ Statuslabel::factory()->archived()->create(['name' => 'Archived']);
+ Statuslabel::factory()->outForDiagnostics()->create();
+ Statuslabel::factory()->outForRepair()->create();
+ Statuslabel::factory()->broken()->create();
+ Statuslabel::factory()->lost()->create();
}
}
diff --git a/database/seeds/SupplierSeeder.php b/database/seeds/SupplierSeeder.php
index 98336205bb..1dc4396610 100644
--- a/database/seeds/SupplierSeeder.php
+++ b/database/seeds/SupplierSeeder.php
@@ -8,6 +8,6 @@ class SupplierSeeder extends Seeder
public function run()
{
Supplier::truncate();
- factory(Supplier::class, 5)->create();
+ Supplier::factory()->count(5)->create();
}
}
diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php
index 9e088df426..5b46ef712b 100644
--- a/database/seeds/UserSeeder.php
+++ b/database/seeds/UserSeeder.php
@@ -13,10 +13,10 @@ class UserSeeder extends Seeder
public function run()
{
User::truncate();
- factory(User::class, 1)->states('first-admin')->create();
- factory(User::class, 1)->states('snipe-admin')->create();
- factory(User::class, 3)->states('superuser')->create();
- factory(User::class, 3)->states('admin')->create();
- factory(User::class, 50)->states('view-assets')->create();
+ User::factory()->count(1)->firstAdmin()->create();
+ User::factory()->count(1)->snipeAdmin()->create();
+ User::factory()->count(3)->superuser()->create();
+ User::factory()->count(3)->admin()->create();
+ User::factory()->count(50)->viewAssets()->create();
}
}
diff --git a/tests/api/ApiAccessoriesCest.php b/tests/api/ApiAccessoriesCest.php
index 57d7fef4cc..8d124268f5 100644
--- a/tests/api/ApiAccessoriesCest.php
+++ b/tests/api/ApiAccessoriesCest.php
@@ -39,7 +39,7 @@ class ApiAccessoriesCest
{
$I->wantTo('Create a new accessory');
- $temp_accessory = factory(\App\Models\Accessory::class)->states('apple-bt-keyboard')->make([
+ $temp_accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->make([
'name' => 'Test Accessory Name',
'company_id' => 2,
]);
@@ -74,14 +74,14 @@ class ApiAccessoriesCest
$I->wantTo('Update an accessory with PATCH');
// create
- $accessory = factory(\App\Models\Accessory::class)->states('apple-bt-keyboard')->create([
+ $accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->create([
'name' => 'Original Accessory Name',
'company_id' => 2,
'location_id' => 3,
]);
$I->assertInstanceOf(\App\Models\Accessory::class, $accessory);
- $temp_accessory = factory(\App\Models\Accessory::class)->states('microsoft-mouse')->make([
+ $temp_accessory = \App\Models\Accessory::factory()->microsoftMouse()->make([
'company_id' => 3,
'name' => 'updated accessory name',
'location_id' => 1,
@@ -133,7 +133,7 @@ class ApiAccessoriesCest
$I->wantTo('Delete an accessory');
// create
- $accessory = factory(\App\Models\Accessory::class)->states('apple-bt-keyboard')->create([
+ $accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Accessory::class, $accessory);
diff --git a/tests/api/ApiAssetsCest.php b/tests/api/ApiAssetsCest.php
index dd102a19fc..554d4c4230 100644
--- a/tests/api/ApiAssetsCest.php
+++ b/tests/api/ApiAssetsCest.php
@@ -46,7 +46,7 @@ class ApiAssetsCest
{
$I->wantTo('Create a new asset');
- $temp_asset = factory(\App\Models\Asset::class)->states('laptop-mbp')->make([
+ $temp_asset = \App\Models\Asset::factory()->laptopMbp()->make([
'asset_tag' => 'Test Asset Tag',
'company_id' => 2,
]);
@@ -81,13 +81,13 @@ class ApiAssetsCest
$I->wantTo('Update an asset with PATCH');
// create
- $asset = factory(\App\Models\Asset::class)->states('laptop-mbp')->create([
+ $asset = \App\Models\Asset::factory()->laptopMbp()->create([
'company_id' => 2,
'rtd_location_id' => 3,
]);
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
- $temp_asset = factory(\App\Models\Asset::class)->states('laptop-air')->make([
+ $temp_asset = \App\Models\Asset::factory()->laptopAir()->make([
'company_id' => 3,
'name' => 'updated asset name',
'rtd_location_id' => 1,
@@ -144,7 +144,7 @@ class ApiAssetsCest
$I->wantTo('Delete an asset');
// create
- $asset = factory(\App\Models\Asset::class)->states('laptop-mbp')->create();
+ $asset = \App\Models\Asset::factory()->laptopMbp()->create();
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
// delete
diff --git a/tests/api/ApiCategoriesCest.php b/tests/api/ApiCategoriesCest.php
index e51aad5a0a..7605872a17 100644
--- a/tests/api/ApiCategoriesCest.php
+++ b/tests/api/ApiCategoriesCest.php
@@ -40,7 +40,7 @@ class ApiCategoriesCest
{
$I->wantTo('Create a new category');
- $temp_category = factory(\App\Models\Category::class)->states('asset-laptop-category')->make([
+ $temp_category = \App\Models\Category::factory()->assetLaptopCategory()->make([
'name' => 'Test Category Tag',
]);
@@ -69,14 +69,13 @@ class ApiCategoriesCest
$I->wantTo('Update an category with PATCH');
// create
- $category = factory(\App\Models\Category::class)->states('asset-laptop-category')
+ $category = \App\Models\Category::factory()->assetLaptopCategory()
->create([
'name' => 'Original Category Name',
]);
$I->assertInstanceOf(\App\Models\Category::class, $category);
- $temp_category = factory(\App\Models\Category::class)
- ->states('accessory-mouse-category')->make([
+ $temp_category = \App\Models\Category::factory()->accessoryMouseCategory()->make([
'name' => 'updated category name',
]);
@@ -120,7 +119,7 @@ class ApiCategoriesCest
$I->wantTo('Delete an category');
// create
- $category = factory(\App\Models\Category::class)->states('asset-laptop-category')->create([
+ $category = \App\Models\Category::factory()->assetLaptopCategory()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Category::class, $category);
diff --git a/tests/api/ApiCheckoutAssetsCest.php b/tests/api/ApiCheckoutAssetsCest.php
index 4e137785d2..48b4bd2335 100644
--- a/tests/api/ApiCheckoutAssetsCest.php
+++ b/tests/api/ApiCheckoutAssetsCest.php
@@ -25,7 +25,7 @@ class ApiCheckoutAssetsCest
$I->wantTo('Check out an asset to a user');
//Grab an asset from the database that isn't checked out.
$asset = Asset::whereNull('assigned_to')->first();
- $targetUser = factory(\App\Models\User::class)->create();
+ $targetUser = \App\Models\User::factory()->create();
$data = [
'assigned_user' => $targetUser->id,
'note' => 'This is a test checkout note',
@@ -62,7 +62,7 @@ class ApiCheckoutAssetsCest
->where('model_id', 8)
->where('status_id', Statuslabel::deployable()->first()->id)
->first(); // We need to make sure that this is an asset/model that doesn't require acceptance
- $targetAsset = factory(\App\Models\Asset::class)->states('desktop-macpro')->create([
+ $targetAsset = \App\Models\Asset::factory()->desktopMacpro()->create([
'name' => 'Test Asset For Checkout to',
]);
$data = [
@@ -96,7 +96,7 @@ class ApiCheckoutAssetsCest
->where('model_id', 8)
->where('status_id', Statuslabel::deployable()->first()->id)
->first(); // We need to make sure that this is an asset/model that doesn't require acceptance
- $targetLocation = factory(\App\Models\Location::class)->create([
+ $targetLocation = \App\Models\Location::factory()->create([
'name' => 'Test Location for Checkout',
]);
$data = [
diff --git a/tests/api/ApiCompaniesCest.php b/tests/api/ApiCompaniesCest.php
index 17ac7c1714..55fa5bc218 100644
--- a/tests/api/ApiCompaniesCest.php
+++ b/tests/api/ApiCompaniesCest.php
@@ -42,7 +42,7 @@ class ApiCompaniesCest
{
$I->wantTo('Create a new company');
- $temp_company = factory(\App\Models\Company::class)->make([
+ $temp_company = \App\Models\Company::factory()->make([
'name' => 'Test Company Tag',
]);
@@ -66,12 +66,12 @@ class ApiCompaniesCest
$I->wantTo('Update an company with PATCH');
// create
- $company = factory(\App\Models\Company::class)->create([
+ $company = \App\Models\Company::factory()->create([
'name' => 'Original Company Name',
]);
$I->assertInstanceOf(\App\Models\Company::class, $company);
- $temp_company = factory(\App\Models\Company::class)->make([
+ $temp_company = \App\Models\Company::factory()->make([
'name' => 'updated company name',
]);
@@ -110,7 +110,7 @@ class ApiCompaniesCest
$I->wantTo('Delete an company');
// create
- $company = factory(\App\Models\Company::class)->create([
+ $company = \App\Models\Company::factory()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Company::class, $company);
diff --git a/tests/api/ApiComponentsCest.php b/tests/api/ApiComponentsCest.php
index 8f9b50b044..dea9ece186 100644
--- a/tests/api/ApiComponentsCest.php
+++ b/tests/api/ApiComponentsCest.php
@@ -40,7 +40,7 @@ class ApiComponentsCest
{
$I->wantTo('Create a new component');
- $temp_component = factory(\App\Models\Component::class)->states('ram-crucial4')->make([
+ $temp_component = \App\Models\Component::factory()->ramCrucial4()->make([
'name' => 'Test Component Name',
'company_id' => 2,
]);
@@ -75,14 +75,14 @@ class ApiComponentsCest
$I->wantTo('Update an component with PATCH');
// create
- $component = factory(\App\Models\Component::class)->states('ram-crucial4')->create([
+ $component = \App\Models\Component::factory()->ramCrucial4()->create([
'name' => 'Original Component Name',
'company_id' => 2,
'location_id' => 3,
]);
$I->assertInstanceOf(\App\Models\Component::class, $component);
- $temp_component = factory(\App\Models\Component::class)->states('ssd-crucial240')->make([
+ $temp_component = \App\Models\Component::factory()->ssdCrucial240()->make([
'company_id' => 3,
'name' => 'updated component name',
'location_id' => 1,
@@ -132,7 +132,7 @@ class ApiComponentsCest
$I->wantTo('Delete an component');
// create
- $component = factory(\App\Models\Component::class)->states('ram-crucial4')->create([
+ $component = \App\Models\Component::factory()->ramCrucial4()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Component::class, $component);
diff --git a/tests/api/ApiConsumablesCest.php b/tests/api/ApiConsumablesCest.php
index 9f453f4f1b..8490c3a56e 100644
--- a/tests/api/ApiConsumablesCest.php
+++ b/tests/api/ApiConsumablesCest.php
@@ -40,7 +40,7 @@ class ApiConsumablesCest
{
$I->wantTo('Create a new consumable');
- $temp_consumable = factory(\App\Models\Consumable::class)->states('ink')->make([
+ $temp_consumable = \App\Models\Consumable::factory()->ink()->make([
'name' => 'Test Consumable Name',
'company_id' => 2,
]);
@@ -74,14 +74,14 @@ class ApiConsumablesCest
$I->wantTo('Update an consumable with PATCH');
// create
- $consumable = factory(\App\Models\Consumable::class)->states('ink')->create([
+ $consumable = \App\Models\Consumable::factory()->ink()->create([
'name' => 'Original Consumable Name',
'company_id' => 2,
'location_id' => 3,
]);
$I->assertInstanceOf(\App\Models\Consumable::class, $consumable);
- $temp_consumable = factory(\App\Models\Consumable::class)->states('cardstock')->make([
+ $temp_consumable = \App\Models\Consumable::factory()->cardstock()->make([
'company_id' => 3,
'name' => 'updated consumable name',
'location_id' => 1,
@@ -133,7 +133,7 @@ class ApiConsumablesCest
$I->wantTo('Delete an consumable');
// create
- $consumable = factory(\App\Models\Consumable::class)->states('ink')->create([
+ $consumable = \App\Models\Consumable::factory()->ink()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Consumable::class, $consumable);
diff --git a/tests/api/ApiLicensesCest.php b/tests/api/ApiLicensesCest.php
index 22744412b6..0668e87628 100644
--- a/tests/api/ApiLicensesCest.php
+++ b/tests/api/ApiLicensesCest.php
@@ -41,7 +41,7 @@ class ApiLicensesCest
{
$I->wantTo('Create a new license');
- $temp_license = factory(\App\Models\License::class)->states('acrobat')->make([
+ $temp_license = \App\Models\License::factory()->acrobat()->make([
'name' => 'Test License Name',
'depreciation_id' => 3,
'company_id' => 2,
@@ -84,14 +84,14 @@ class ApiLicensesCest
$I->wantTo('Update a license with PATCH');
// create
- $license = factory(\App\Models\License::class)->states('acrobat')->create([
+ $license = \App\Models\License::factory()->acrobat()->create([
'name' => 'Original License Name',
'depreciation_id' => 3,
'company_id' => 2,
]);
$I->assertInstanceOf(\App\Models\License::class, $license);
- $temp_license = factory(\App\Models\License::class)->states('office')->make([
+ $temp_license = \App\Models\License::factory()->office()->make([
'company_id' => 3,
'depreciation_id' => 2,
]);
@@ -147,7 +147,7 @@ class ApiLicensesCest
$I->wantTo('Ensure a license with seats checked out cannot be deleted');
// create
- $license = factory(\App\Models\License::class)->states('acrobat')->create([
+ $license = \App\Models\License::factory()->acrobat()->create([
'name' => 'Soon to be deleted',
]);
$licenseSeat = $license->freeSeat();
@@ -171,7 +171,7 @@ class ApiLicensesCest
$I->wantTo('Delete an license');
// create
- $license = factory(\App\Models\License::class)->states('acrobat')->create([
+ $license = \App\Models\License::factory()->acrobat()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\License::class, $license);
diff --git a/tests/api/ApiLocationsCest.php b/tests/api/ApiLocationsCest.php
index 2f185d084a..536830f00d 100644
--- a/tests/api/ApiLocationsCest.php
+++ b/tests/api/ApiLocationsCest.php
@@ -41,7 +41,7 @@ class ApiLocationsCest
{
$I->wantTo('Create a new location');
- $temp_location = factory(\App\Models\Location::class)->make([
+ $temp_location = \App\Models\Location::factory()->make([
'name' => 'Test Location Tag',
]);
@@ -76,12 +76,12 @@ class ApiLocationsCest
$I->wantTo('Update an location with PATCH');
// create
- $location = factory(\App\Models\Location::class)->create([
+ $location = \App\Models\Location::factory()->create([
'name' => 'Original Location Name',
]);
$I->assertInstanceOf(\App\Models\Location::class, $location);
- $temp_location = factory(\App\Models\Location::class)->make([
+ $temp_location = \App\Models\Location::factory()->make([
'name' => 'updated location name',
]);
@@ -132,7 +132,7 @@ class ApiLocationsCest
$I->wantTo('Delete an location');
// create
- $location = factory(\App\Models\Location::class)->create([
+ $location = \App\Models\Location::factory()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Location::class, $location);
diff --git a/tests/api/ApiManufacturersCest.php b/tests/api/ApiManufacturersCest.php
index cd9afff031..be2f4cc483 100644
--- a/tests/api/ApiManufacturersCest.php
+++ b/tests/api/ApiManufacturersCest.php
@@ -41,7 +41,7 @@ class ApiManufacturersCest
{
$I->wantTo('Create a new manufacturer');
- $temp_manufacturer = factory(\App\Models\Manufacturer::class)->states('apple')->make([
+ $temp_manufacturer = \App\Models\Manufacturer::factory()->apple()->make([
'name' => 'Test Manufacturer Tag',
]);
@@ -70,13 +70,13 @@ class ApiManufacturersCest
$I->wantTo('Update an manufacturer with PATCH');
// create
- $manufacturer = factory(\App\Models\Manufacturer::class)->states('apple')
+ $manufacturer = \App\Models\Manufacturer::factory()->apple()
->create([
'name' => 'Original Manufacturer Name',
]);
$I->assertInstanceOf(\App\Models\Manufacturer::class, $manufacturer);
- $temp_manufacturer = factory(\App\Models\Manufacturer::class)->states('dell')->make([
+ $temp_manufacturer = \App\Models\Manufacturer::factory()->dell()->make([
'name' => 'updated manufacturer name',
]);
@@ -120,7 +120,7 @@ class ApiManufacturersCest
$I->wantTo('Delete an manufacturer');
// create
- $manufacturer = factory(\App\Models\Manufacturer::class)->states('apple')->create([
+ $manufacturer = \App\Models\Manufacturer::factory()->apple()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Manufacturer::class, $manufacturer);
diff --git a/tests/api/ApiModelsCest.php b/tests/api/ApiModelsCest.php
index 9db4742eb8..1d3d6fc788 100644
--- a/tests/api/ApiModelsCest.php
+++ b/tests/api/ApiModelsCest.php
@@ -39,7 +39,7 @@ class ApiModelsCest
{
$I->wantTo('Create a new assetmodel');
- $temp_assetmodel = factory(\App\Models\AssetModel::class)->states('mbp-13-model')->make([
+ $temp_assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->make([
'name' => 'Test AssetModel Tag',
]);
@@ -70,12 +70,12 @@ class ApiModelsCest
$I->wantTo('Update an assetmodel with PATCH');
// create
- $assetmodel = factory(\App\Models\AssetModel::class)->states('mbp-13-model')->create([
+ $assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->create([
'name' => 'Original AssetModel Name',
]);
$I->assertInstanceOf(\App\Models\AssetModel::class, $assetmodel);
- $temp_assetmodel = factory(\App\Models\AssetModel::class)->states('polycomcx-model')->make([
+ $temp_assetmodel = \App\Models\AssetModel::factory()->polycomcxModel()->make([
'name' => 'updated AssetModel name',
'fieldset_id' => 2,
]);
@@ -123,7 +123,7 @@ class ApiModelsCest
$I->wantTo('Delete an assetmodel');
// create
- $assetmodel = factory(\App\Models\AssetModel::class)->states('mbp-13-model')->create([
+ $assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\AssetModel::class, $assetmodel);
diff --git a/tests/api/ApiStatusLabelsCest.php b/tests/api/ApiStatusLabelsCest.php
index 5c14ed36b7..fabb71d51f 100644
--- a/tests/api/ApiStatusLabelsCest.php
+++ b/tests/api/ApiStatusLabelsCest.php
@@ -41,7 +41,7 @@ class ApiStatusLabelsCest
{
$I->wantTo('Create a new statuslabel');
- $temp_statuslabel = factory(\App\Models\Statuslabel::class)->make([
+ $temp_statuslabel = \App\Models\Statuslabel::factory()->make([
'name' => 'Test Statuslabel Tag',
]);
@@ -70,12 +70,12 @@ class ApiStatusLabelsCest
$I->wantTo('Update an statuslabel with PATCH');
// create
- $statuslabel = factory(\App\Models\Statuslabel::class)->states('rtd')->create([
+ $statuslabel = \App\Models\Statuslabel::factory()->rtd()->create([
'name' => 'Original Statuslabel Name',
]);
$I->assertInstanceOf(\App\Models\Statuslabel::class, $statuslabel);
- $temp_statuslabel = factory(\App\Models\Statuslabel::class)->states('pending')->make([
+ $temp_statuslabel = \App\Models\Statuslabel::factory()->pending()->make([
'name' => 'updated statuslabel name',
'type' => 'pending',
]);
@@ -120,7 +120,7 @@ class ApiStatusLabelsCest
$I->wantTo('Delete an statuslabel');
// create
- $statuslabel = factory(\App\Models\Statuslabel::class)->create([
+ $statuslabel = \App\Models\Statuslabel::factory()->create([
'name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\Statuslabel::class, $statuslabel);
diff --git a/tests/api/ApiUsersCest.php b/tests/api/ApiUsersCest.php
index ce938489b2..912653be2d 100644
--- a/tests/api/ApiUsersCest.php
+++ b/tests/api/ApiUsersCest.php
@@ -42,10 +42,10 @@ class ApiUsersCest
{
$I->wantTo('Create a new user');
- $temp_user = factory(\App\Models\User::class)->make([
+ $temp_user = \App\Models\User::factory()->make([
'name' => 'Test User Name',
]);
- factory(Group::class, 2)->create();
+ Group::factory()->count(2)->create();
$groups = Group::pluck('id');
// setup
$data = [
@@ -90,20 +90,20 @@ class ApiUsersCest
$I->wantTo('Update an user with PATCH');
// create
- $user = factory(\App\Models\User::class)->create([
+ $user = \App\Models\User::factory()->create([
'first_name' => 'Original User Name',
'company_id' => 2,
'location_id' => 3,
]);
$I->assertInstanceOf(\App\Models\User::class, $user);
- $temp_user = factory(\App\Models\User::class)->make([
+ $temp_user = \App\Models\User::factory()->make([
'company_id' => 3,
'first_name' => 'updated user name',
'location_id' => 1,
]);
- factory(Group::class, 2)->create();
+ Group::factory()->count(2)->create();
$groups = Group::pluck('id');
$data = [
@@ -163,7 +163,7 @@ class ApiUsersCest
$I->wantTo('Delete an user');
// create
- $user = factory(\App\Models\User::class)->create([
+ $user = \App\Models\User::factory()->create([
'first_name' => 'Soon to be deleted',
]);
$I->assertInstanceOf(\App\Models\User::class, $user);
diff --git a/tests/functional/AccessoriesCest.php b/tests/functional/AccessoriesCest.php
index 92096e763d..bee341b361 100644
--- a/tests/functional/AccessoriesCest.php
+++ b/tests/functional/AccessoriesCest.php
@@ -52,7 +52,7 @@ class AccessoriesCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $accessory = factory(App\Models\Accessory::class)->states('apple-bt-keyboard')->make();
+ $accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->make();
$values = [
'category_id' => $accessory->category_id,
'location_id' => $accessory->location_id,
diff --git a/tests/functional/AssetModelsCest.php b/tests/functional/AssetModelsCest.php
index e3a23b4e0d..fbf43a5c57 100644
--- a/tests/functional/AssetModelsCest.php
+++ b/tests/functional/AssetModelsCest.php
@@ -33,7 +33,7 @@ class AssetModelsCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $model = factory(App\Models\AssetModel::class)->states('mbp-13-model')->make(['name'=>'Test Model']);
+ $model = \App\Models\AssetModel::factory()->mbp13Model()->make(['name'=>'Test Model']);
$values = [
'category_id' => $model->category_id,
'depreciation_id' => $model->depreciation_id,
@@ -56,7 +56,7 @@ class AssetModelsCest
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete an asset model');
- $model = factory(App\Models\AssetModel::class)->states('mbp-13-model')->create(['name' => 'Test Model']);
+ $model = \App\Models\AssetModel::factory()->mbp13Model()->create(['name' => 'Test Model']);
$I->sendDelete(route('models.destroy', $model->id), ['_token' => csrf_token()]);
$I->seeResponseCodeIs(200);
}
diff --git a/tests/functional/AssetsCest.php b/tests/functional/AssetsCest.php
index e08b26069c..3c7ffc1282 100644
--- a/tests/functional/AssetsCest.php
+++ b/tests/functional/AssetsCest.php
@@ -34,7 +34,7 @@ class AssetsCest
public function passesCreateAndCheckout(FunctionalTester $I)
{
- $asset = factory(App\Models\Asset::class)->states('laptop-mbp')->make([
+ $asset = \App\Models\Asset::factory()->laptopMbp()->make([
'asset_tag'=>'test tag',
'name'=> 'test asset',
'company_id'=>1,
diff --git a/tests/functional/CategoriesCest.php b/tests/functional/CategoriesCest.php
index 49dbf11ff5..ff89fcc152 100644
--- a/tests/functional/CategoriesCest.php
+++ b/tests/functional/CategoriesCest.php
@@ -36,7 +36,7 @@ class CategoriesCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $category = factory(App\Models\Category::class)->states('asset-laptop-category')->make([
+ $category = \App\Models\Category::factory()->assetLaptopCategory()->make([
'name' => 'Test Category',
]);
$values = [
@@ -57,7 +57,7 @@ class CategoriesCest
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a category');
- $category = factory(App\Models\Category::class)->states('asset-laptop-category')->create([
+ $category = \App\Models\Category::factory()->assetLaptopCategory()->create([
'name'=>'Deletable Test Category',
]);
$I->sendDelete(route('categories.destroy', $category->id), ['_token' => csrf_token()]);
diff --git a/tests/functional/CompaniesCest.php b/tests/functional/CompaniesCest.php
index af7ce713f8..75724aa206 100644
--- a/tests/functional/CompaniesCest.php
+++ b/tests/functional/CompaniesCest.php
@@ -31,7 +31,7 @@ class CompaniesCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $company = factory(App\Models\Company::class)->make();
+ $company = \App\Models\Company::factory()->make();
$values = [
'name' => $company->name,
];
diff --git a/tests/functional/ComponentsCest.php b/tests/functional/ComponentsCest.php
index 092bd8ccc2..6e2a7f136b 100644
--- a/tests/functional/ComponentsCest.php
+++ b/tests/functional/ComponentsCest.php
@@ -46,7 +46,7 @@ class ComponentsCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $component = factory(App\Models\Component::class)->states('ram-crucial4')->make([
+ $component = \App\Models\Component::factory()->ramCrucial4()->make([
'name' => 'Test Component',
'serial' => '3523-235325-1350235',
]);
diff --git a/tests/functional/ConsumablesCest.php b/tests/functional/ConsumablesCest.php
index cfca37a770..c47eb23c0f 100644
--- a/tests/functional/ConsumablesCest.php
+++ b/tests/functional/ConsumablesCest.php
@@ -47,7 +47,7 @@ class ConsumablesCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $consumable = factory(App\Models\Consumable::class)->states('cardstock')->make([
+ $consumable = \App\Models\Consumable::factory()->cardstock()->make([
'name' => 'Test Consumable',
'model_number' => 23520,
]);
diff --git a/tests/functional/DepreciationsCest.php b/tests/functional/DepreciationsCest.php
index acf2d561db..25dcfaef1f 100644
--- a/tests/functional/DepreciationsCest.php
+++ b/tests/functional/DepreciationsCest.php
@@ -43,7 +43,7 @@ class DepreciationsCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $depreciation = factory(App\Models\Depreciation::class)->states('computer')->make([
+ $depreciation = \App\Models\Depreciation::factory()->computer()->make([
'name'=>'Test Depreciation',
]);
$values = [
diff --git a/tests/functional/LicensesCest.php b/tests/functional/LicensesCest.php
index a5d95450ba..5add67f51d 100644
--- a/tests/functional/LicensesCest.php
+++ b/tests/functional/LicensesCest.php
@@ -47,7 +47,7 @@ class LicensesCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $license = factory(App\Models\License::class)->states('photoshop')->make([
+ $license = \App\Models\License::factory()->photoshop()->make([
'name' => 'Test License',
'company_id' => 3,
]);
diff --git a/tests/functional/LocationsCest.php b/tests/functional/LocationsCest.php
index 3ab0b60a57..9177c6ae4b 100644
--- a/tests/functional/LocationsCest.php
+++ b/tests/functional/LocationsCest.php
@@ -45,7 +45,7 @@ class LocationsCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $location = factory(App\Models\Location::class)->make();
+ $location = \App\Models\Location::factory()->make();
$values = [
'name' => $location->name,
'parent_id' => $I->getLocationId(),
@@ -67,7 +67,7 @@ class LocationsCest
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a location');
- $location = factory(App\Models\Location::class)->create();
+ $location = \App\Models\Location::factory()->create();
$I->sendDelete(route('locations.destroy', $location->id), ['_token' => csrf_token()]);
$I->seeResponseCodeIs(200);
}
diff --git a/tests/functional/ManufacturersCest.php b/tests/functional/ManufacturersCest.php
index 0a1f9dc8f7..65c8b1d190 100644
--- a/tests/functional/ManufacturersCest.php
+++ b/tests/functional/ManufacturersCest.php
@@ -43,7 +43,7 @@ class ManufacturersCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $manufacturer = factory(App\Models\Manufacturer::class)->states('microsoft')->make([
+ $manufacturer = \App\Models\Manufacturer::factory()->microsoft()->make([
'name' => 'Test Manufacturer',
]);
$values = [
@@ -59,7 +59,7 @@ class ManufacturersCest
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a manufacturer');
- $manufacturerId = factory(App\Models\Manufacturer::class)->states('microsoft')->create(['name' => 'Deletable Test Manufacturer'])->id;
+ $manufacturerId = \App\Models\Manufacturer::factory()->microsoft()->create(['name' => 'Deletable Test Manufacturer'])->id;
$I->sendDelete(route('manufacturers.destroy', $manufacturerId), ['_token' => csrf_token()]);
$I->seeResponseCodeIs(200);
}
diff --git a/tests/functional/StatusLabelsCest.php b/tests/functional/StatusLabelsCest.php
index e6807c247f..ff1ec90961 100644
--- a/tests/functional/StatusLabelsCest.php
+++ b/tests/functional/StatusLabelsCest.php
@@ -33,7 +33,7 @@ class StatusLabelsCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $status = factory(App\Models\Statuslabel::class)->states('pending')->make();
+ $status = \App\Models\Statuslabel::factory()->pending()->make();
$submitValues = [
'name' => 'Testing Status',
'statuslabel_types' => 'pending',
diff --git a/tests/functional/SuppliersCest.php b/tests/functional/SuppliersCest.php
index ed80088f24..69746f86a5 100644
--- a/tests/functional/SuppliersCest.php
+++ b/tests/functional/SuppliersCest.php
@@ -31,7 +31,7 @@ class SuppliersCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $supplier = factory(App\Models\Supplier::class)->make();
+ $supplier = \App\Models\Supplier::factory()->make();
$values = [
'name' => $supplier->name,
@@ -58,7 +58,7 @@ class SuppliersCest
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a supplier');
- $supplier = factory(App\Models\Supplier::class)->create();
+ $supplier = \App\Models\Supplier::factory()->create();
$I->sendDelete(route('suppliers.destroy', $supplier->id), ['_token' => csrf_token()]);
$I->seeResponseCodeIs(200);
}
diff --git a/tests/functional/UsersCest.php b/tests/functional/UsersCest.php
index a235415dc2..e861694918 100644
--- a/tests/functional/UsersCest.php
+++ b/tests/functional/UsersCest.php
@@ -48,7 +48,7 @@ class UsersCest
public function passesCorrectValidation(FunctionalTester $I)
{
- $user = factory(App\Models\User::class)->make();
+ $user = \App\Models\User::factory()->make();
$submitValues = [
'first_name' => $user->first_name,
'last_name' => $user->last_name,
@@ -90,7 +90,7 @@ class UsersCest
public function allowsDelete(FunctionalTester $I)
{
- $user = factory(App\Models\User::class)->create();
+ $user = \App\Models\User::factory()->create();
$I->wantTo('Ensure I can delete a user');
$I->sendDelete(route('users.destroy', $user->id), ['_token' => csrf_token()]);
$I->seeResponseCodeIs(200);
diff --git a/tests/unit/AccessoryTest.php b/tests/unit/AccessoryTest.php
index 0fff1c87fc..a3c7e73372 100644
--- a/tests/unit/AccessoryTest.php
+++ b/tests/unit/AccessoryTest.php
@@ -35,7 +35,7 @@ class AccessoryTest extends BaseTest
// An Accessory name has a min length of 3
// An Accessory has a min qty of 1
// An Accessory has a min amount of 0
- $a = factory(Accessory::class)->make([
+ $a = Accessory::factory()->make([
'name' => 'a',
'qty' => 0,
'min_amt' => -1,
@@ -55,13 +55,13 @@ class AccessoryTest extends BaseTest
public function testCategoryIdMustExist()
{
$category = $this->createValidCategory('accessory-keyboard-category', ['category_type' => 'accessory']);
- $accessory = factory(Accessory::class)->states('apple-bt-keyboard')->make(['category_id' => $category->id]);
+ $accessory = Accessory::factory()->appleBtKeyboard()->make(['category_id' => $category->id]);
$this->createValidManufacturer('apple');
$accessory->save();
$this->assertTrue($accessory->isValid());
$newId = $category->id + 1;
- $accessory = factory(Accessory::class)->states('apple-bt-keyboard')->make(['category_id' => $newId]);
+ $accessory = Accessory::factory()->appleBtKeyboard()->make(['category_id' => $newId]);
$accessory->save();
$this->assertFalse($accessory->isValid());
@@ -70,22 +70,22 @@ class AccessoryTest extends BaseTest
public function testAnAccessoryBelongsToACompany()
{
- $accessory = factory(Accessory::class)
- ->create(['company_id' => factory(App\Models\Company::class)->create()->id]);
+ $accessory = Accessory::factory()
+ ->create(['company_id' => \App\Models\Company::factory()->create()->id]);
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
}
public function testAnAccessoryHasALocation()
{
- $accessory = factory(Accessory::class)
- ->create(['location_id' => factory(App\Models\Location::class)->create()->id]);
+ $accessory = Accessory::factory()
+ ->create(['location_id' => \App\Models\Location::factory()->create()->id]);
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
}
public function testAnAccessoryBelongsToACategory()
{
- $accessory = factory(Accessory::class)->states('apple-bt-keyboard')
- ->create(['category_id' => factory(Category::class)->states('accessory-keyboard-category')->create(['category_type' => 'accessory'])->id]);
+ $accessory = Accessory::factory()->appleBtKeyboard()
+ ->create(['category_id' => Category::factory()->accessoryKeyboardCategory()->create(['category_type' => 'accessory'])->id]);
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
$this->assertEquals('accessory', $accessory->category->category_type);
}
@@ -94,7 +94,7 @@ class AccessoryTest extends BaseTest
{
$this->createValidManufacturer('apple');
$this->createValidCategory('accessory-keyboard-category');
- $accessory = factory(Accessory::class)->states('apple-bt-keyboard')->create(['category_id' => 1]);
+ $accessory = Accessory::factory()->appleBtKeyboard()->create(['category_id' => 1]);
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
}
}
diff --git a/tests/unit/AssetTest.php b/tests/unit/AssetTest.php
index e27f535920..84b83f1f27 100644
--- a/tests/unit/AssetTest.php
+++ b/tests/unit/AssetTest.php
@@ -74,7 +74,7 @@ class AssetTest extends BaseTest
*/
public function testWarrantyExpiresAttribute()
{
- $asset = factory(Asset::class)->states('laptop-mbp')->create([
+ $asset = Asset::factory()->laptopMbp()->create([
'model_id' => $this->createValidAssetModel()->id,
'supplier_id' => $this->createvalidSupplier()->id,
'rtd_location_id' => $this->createValidLocation()->id,
@@ -110,7 +110,7 @@ class AssetTest extends BaseTest
public function testModelIdMustExist()
{
$model = $this->createValidAssetModel();
- $asset = factory(Asset::class)->make([
+ $asset = Asset::factory()->make([
'model_id' => $model->id,
'supplier_id' => $this->createValidSupplier()->id,
'rtd_location_id' => $this->createValidLocation()->id,
@@ -118,7 +118,7 @@ class AssetTest extends BaseTest
$asset->save();
$this->assertTrue($asset->isValid());
$newId = $model->id + 1;
- $asset = factory(Asset::class)->make(['model_id' => $newId]);
+ $asset = Asset::factory()->make(['model_id' => $newId]);
$asset->save();
$this->assertFalse($asset->isValid());
@@ -126,7 +126,7 @@ class AssetTest extends BaseTest
public function testAnAssetHasRelationships()
{
- $asset = factory(Asset::class)->states('laptop-mbp')
+ $asset = Asset::factory()->laptopMbp()
->create([
'model_id' => $this->createValidAssetModel()->id,
'company_id' => $this->createValidCompany()->id,
@@ -147,13 +147,12 @@ class AssetTest extends BaseTest
// Then it is available for checkout
// An asset assigned to someone should not be available for checkout.
- $assetAssigned = factory(Asset::class)
- ->states('laptop-mbp', 'assigned-to-user')
+ $assetAssigned = Asset::factory()->laptopMbp()->assignedToUser()
->create(['model_id' => $this->createValidAssetModel()]);
$this->assertFalse($assetAssigned->availableForCheckout());
// An asset with a non deployable statuslabel should not be available for checkout.
- $assetUndeployable = factory(Asset::class)->create([
+ $assetUndeployable = Asset::factory()->create([
'status_id' => $this->createValidStatuslabel('archived')->id,
'model_id' => $this->createValidAssetModel(),
]);
@@ -161,13 +160,13 @@ class AssetTest extends BaseTest
$this->assertFalse($assetUndeployable->availableForCheckout());
// An asset that has been deleted is not avaiable for checkout.
- $assetDeleted = factory(Asset::class)->states('deleted')->create([
+ $assetDeleted = Asset::factory()->deleted()->create([
'model_id' => $this->createValidAssetModel(),
]);
$this->assertFalse($assetDeleted->availableForCheckout());
// A ready to deploy asset that isn't assigned to anyone is available for checkout
- $asset = factory(Asset::class)->create([
+ $asset = Asset::factory()->create([
'status_id' => $this->createValidStatuslabel('rtd')->id,
'model_id' => $this->createValidAssetModel(),
]);
@@ -178,7 +177,7 @@ class AssetTest extends BaseTest
{
$asset = $this->createValidAsset();
- $components = factory(App\Models\Component::class, 5)->states('ram-crucial4')->create([
+ $components = \App\Models\Component::factory()->count(5)->ramCrucial4()->create([
'category_id' => $this->createValidCategory('component-hdd-category')->id,
]);
@@ -197,7 +196,7 @@ class AssetTest extends BaseTest
'supplier_id' => $this->createValidSupplier()->id,
]);
$this->assertCount(0, $asset->uploads);
- factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
+ \App\Models\Actionlog::factory()->count('asset-upload')->create(['item_id' => $asset->id]);
$this->assertCount(1, $asset->fresh()->uploads);
}
@@ -222,8 +221,8 @@ class AssetTest extends BaseTest
$asset = $this->createValidAsset();
$adminUser = $this->signIn();
- $target = factory(App\Models\User::class)->create([
- 'location_id' => factory(App\Models\Location::class)->create(),
+ $target = \App\Models\User::factory()->create([
+ 'location_id' => \App\Models\Location::factory()->create(),
]);
// An Asset Can be checked out to a user, and this should be logged.
$asset->checkOut($target, $adminUser);
@@ -318,7 +317,7 @@ class AssetTest extends BaseTest
public function testAnAssetHasMaintenances()
{
$asset = $this->createValidAsset();
- factory(App\Models\AssetMaintenance::class)->create(['asset_id' => $asset->id]);
+ \App\Models\AssetMaintenance::factory()->create(['asset_id' => $asset->id]);
$this->assertCount(1, $asset->assetmaintenances);
}
}
diff --git a/tests/unit/BaseTest.php b/tests/unit/BaseTest.php
index f375ef2958..a2e81599b1 100644
--- a/tests/unit/BaseTest.php
+++ b/tests/unit/BaseTest.php
@@ -12,13 +12,13 @@ class BaseTest extends \Codeception\TestCase\Test
protected function _before()
{
Artisan::call('migrate');
- factory(App\Models\Setting::class)->create();
+ \App\Models\Setting::factory()->create();
}
protected function signIn($user = null)
{
if (! $user) {
- $user = factory(User::class)->states('superuser')->create([
+ $user = User::factory()->superuser()->create([
'location_id' => $this->createValidLocation()->id,
]);
}
@@ -29,7 +29,7 @@ class BaseTest extends \Codeception\TestCase\Test
protected function createValidAssetModel($state = 'mbp-13-model', $overrides = [])
{
- return factory(\App\Models\AssetModel::class)->states($state)->create(array_merge([
+ return \App\Models\AssetModel::factory()->state()->create(array_merge([
'category_id' => $this->createValidCategory(),
'manufacturer_id' => $this->createValidManufacturer(),
'depreciation_id' => $this->createValidDepreciation(),
@@ -38,49 +38,49 @@ class BaseTest extends \Codeception\TestCase\Test
protected function createValidCategory($state = 'asset-laptop-category', $overrides = [])
{
- return factory(App\Models\Category::class)->states($state)->create($overrides);
+ return \App\Models\Category::factory()->state()->create($overrides);
}
protected function createValidCompany($overrides = [])
{
- return factory(App\Models\Company::class)->create($overrides);
+ return \App\Models\Company::factory()->create($overrides);
}
protected function createValidDepartment($state = 'engineering', $overrides = [])
{
- return factory(App\Models\Department::class)->states($state)->create(array_merge([
+ return \App\Models\Department::factory()->state()->create(array_merge([
'location_id' => $this->createValidLocation()->id,
], $overrides));
}
protected function createValidDepreciation($state = 'computer', $overrides = [])
{
- return factory(App\Models\Depreciation::class)->states($state)->create($overrides);
+ return \App\Models\Depreciation::factory()->state()->create($overrides);
}
protected function createValidLocation($overrides = [])
{
- return factory(App\Models\Location::class)->create($overrides);
+ return \App\Models\Location::factory()->create($overrides);
}
protected function createValidManufacturer($state = 'apple', $overrides = [])
{
- return factory(App\Models\Manufacturer::class)->states($state)->create($overrides);
+ return \App\Models\Manufacturer::factory()->state()->create($overrides);
}
protected function createValidSupplier($overrides = [])
{
- return factory(App\Models\Supplier::class)->create($overrides);
+ return \App\Models\Supplier::factory()->create($overrides);
}
protected function createValidStatuslabel($state = 'rtd', $overrides = [])
{
- return factory(App\Models\Statuslabel::class)->states($state)->create($overrides);
+ return \App\Models\Statuslabel::factory()->state()->create($overrides);
}
protected function createValidUser($overrides = [])
{
- return factory(App\Models\User::class)->create(
+ return \App\Models\User::factory()->create(
array_merge([
'location_id'=>$this->createValidLocation()->id,
], $overrides)
@@ -92,7 +92,7 @@ class BaseTest extends \Codeception\TestCase\Test
$locId = $this->createValidLocation()->id;
$this->createValidAssetModel();
- return factory(\App\Models\Asset::class)->states('laptop-mbp')->create(
+ return \App\Models\Asset::factory()->laptopMbp()->create(
array_merge([
'rtd_location_id' => $locId,
'location_id' => $locId,
diff --git a/tests/unit/CategoryTest.php b/tests/unit/CategoryTest.php
index 61bfbc72a1..88ca9c3d28 100644
--- a/tests/unit/CategoryTest.php
+++ b/tests/unit/CategoryTest.php
@@ -33,7 +33,7 @@ class CategoryTest extends BaseTest
{
$this->createValidAssetModel(); //This will seed various things to make the following work better.
$category = $this->createValidCategory('asset-desktop-category');
- $models = factory(App\Models\AssetModel::class, 5)->states('mbp-13-model')->create(['category_id' => $category->id]);
+ $models = \App\Models\AssetModel::factory()->count(5)->mbp13Model()->create(['category_id' => $category->id]);
$this->assertEquals(5, $category->models->count());
$this->assertCount(5, $category->models);
@@ -49,7 +49,7 @@ class CategoryTest extends BaseTest
public function testACategoryCanHaveAccessories()
{
$category = $this->createValidCategory('accessory-keyboard-category');
- factory(App\Models\Accessory::class, 5)->states('apple-bt-keyboard')->create(['category_id' => $category->id]);
+ \App\Models\Accessory::factory()->count(5)->appleBtKeyboard()->create(['category_id' => $category->id]);
$this->assertCount(5, $category->accessories);
$this->assertEquals(5, $category->itemCount());
@@ -58,7 +58,7 @@ class CategoryTest extends BaseTest
public function testACategoryCanHaveConsumables()
{
$category = $this->createValidCategory('consumable-paper-category');
- factory(App\Models\Consumable::class, 5)->states('cardstock')->create(['category_id' => $category->id]);
+ \App\Models\Consumable::factory()->count(5)->cardstock()->create(['category_id' => $category->id]);
$this->assertCount(5, $category->consumables);
$this->assertEquals(5, $category->itemCount());
}
@@ -66,7 +66,7 @@ class CategoryTest extends BaseTest
public function testACategoryCanHaveComponents()
{
$category = $this->createValidCategory('component-ram-category');
- factory(App\Models\Component::class, 5)->states('ram-crucial4')->create(['category_id' => $category->id]);
+ \App\Models\Component::factory()->count(5)->ramCrucial4()->create(['category_id' => $category->id]);
$this->assertCount(5, $category->components);
$this->assertEquals(5, $category->itemCount());
}
diff --git a/tests/unit/CompanyTest.php b/tests/unit/CompanyTest.php
index c3d663a42b..7fe40ddb25 100644
--- a/tests/unit/CompanyTest.php
+++ b/tests/unit/CompanyTest.php
@@ -45,10 +45,10 @@ class CompanyTest extends BaseTest
public function testACompanyCanHaveLicenses()
{
$company = $this->createValidCompany();
- factory(App\Models\License::class, 1)->states('acrobat')->create([
+ \App\Models\License::factory()->count(1)->acrobat()->create([
'company_id'=>$company->id,
- 'manufacturer_id' => factory(App\Models\Manufacturer::class)->states('adobe')->create()->id,
- 'category_id' => factory(App\Models\Category::class)->states('license-office-category')->create()->id,
+ 'manufacturer_id' => \App\Models\Manufacturer::factory()->adobe()->create()->id,
+ 'category_id' => \App\Models\Category::factory()->licenseOfficeCategory()->create()->id,
]);
$this->assertCount(1, $company->licenses);
}
@@ -56,8 +56,8 @@ class CompanyTest extends BaseTest
public function testACompanyCanHaveAccessories()
{
$company = $this->createValidCompany();
- $a = factory(App\Models\Accessory::class)->states('apple-bt-keyboard')->create([
- 'category_id' => factory(App\Models\Category::class)->states('accessory-keyboard-category')->create()->id,
+ $a = \App\Models\Accessory::factory()->appleBtKeyboard()->create([
+ 'category_id' => \App\Models\Category::factory()->accessoryKeyboardCategory()->create()->id,
'company_id' => $company->id,
]);
@@ -67,9 +67,9 @@ class CompanyTest extends BaseTest
public function testACompanyCanHaveConsumables()
{
$company = $this->createValidCompany();
- factory(App\Models\Consumable::class, 1)->states('cardstock')->create([
+ \App\Models\Consumable::factory()->count(1)->cardstock()->create([
'company_id' => $company->id,
- 'category_id' => factory(App\Models\Category::class)->states('consumable-paper-category')->create()->id,
+ 'category_id' => \App\Models\Category::factory()->consumablePaperCategory()->create()->id,
]);
$this->assertCount(1, $company->consumables);
}
@@ -77,9 +77,9 @@ class CompanyTest extends BaseTest
public function testACompanyCanHaveComponents()
{
$company = $this->createValidCompany();
- factory(App\Models\Component::class, 1)->states('ram-crucial4')->create([
+ \App\Models\Component::factory()->count(1)->ramCrucial4()->create([
'company_id'=>$company->id,
- 'category_id' => factory(App\Models\Category::class)->states('component-ram-category')->create()->id,
+ 'category_id' => \App\Models\Category::factory()->componentRamCategory()->create()->id,
]);
$this->assertCount(1, $company->components);
}
diff --git a/tests/unit/ComponentTest.php b/tests/unit/ComponentTest.php
index 25aac1f683..985c2c8f7a 100644
--- a/tests/unit/ComponentTest.php
+++ b/tests/unit/ComponentTest.php
@@ -37,7 +37,7 @@ class ComponentTest extends BaseTest
// An Component name has a min length of 3
// An Component has a min qty of 1
// An Component has a min amount of 0
- $a = factory(Component::class)->make([
+ $a = Component::factory()->make([
'name' => 'a',
'qty' => 0,
'min_amt' => -1,
@@ -58,15 +58,14 @@ class ComponentTest extends BaseTest
{
$category = $this->createValidCategory('component-hdd-category',
['category_type' => 'component']);
- $component = factory(Component::class)
- ->states('ssd-crucial240')
+ $component = Component::factory()->ssdCrucial240()
->make(['category_id' => $category->id]);
$this->createValidManufacturer('apple');
$component->save();
$this->assertTrue($component->isValid());
$newId = $category->id + 1;
- $component = factory(Component::class)->states('ssd-crucial240')->make(['category_id' => $newId]);
+ $component = Component::factory()->ssdCrucial240()->make(['category_id' => $newId]);
$component->save();
$this->assertFalse($component->isValid());
@@ -75,24 +74,23 @@ class ComponentTest extends BaseTest
public function testAnComponentBelongsToACompany()
{
- $component = factory(Component::class)
- ->create(['company_id' => factory(Company::class)->create()->id]);
+ $component = Component::factory()
+ ->create(['company_id' => Company::factory()->create()->id]);
$this->assertInstanceOf(Company::class, $component->company);
}
public function testAnComponentHasALocation()
{
- $component = factory(Component::class)
- ->create(['location_id' => factory(Location::class)->create()->id]);
+ $component = Component::factory()
+ ->create(['location_id' => Location::factory()->create()->id]);
$this->assertInstanceOf(Location::class, $component->location);
}
public function testAnComponentBelongsToACategory()
{
- $component = factory(Component::class)->states('ssd-crucial240')
+ $component = Component::factory()->ssdCrucial240()
->create([
- 'category_id' => factory(Category::class)
- ->states('component-hdd-category')
+ 'category_id' => Category::factory()->componentHddCategory()
->create(['category_type' => 'component'])->id,
]);
$this->assertInstanceOf(Category::class, $component->category);
diff --git a/tests/unit/ConsumableTest.php b/tests/unit/ConsumableTest.php
index 2a41824fff..276699e6f2 100644
--- a/tests/unit/ConsumableTest.php
+++ b/tests/unit/ConsumableTest.php
@@ -32,7 +32,7 @@ class ConsumableTest extends BaseTest
public function testAConsumableHasRelationships()
{
- $consumable = factory(Consumable::class)->states('cardstock')->create([
+ $consumable = Consumable::factory()->cardstock()->create([
'category_id' => $this->createValidCategory('consumable-paper-category')->id,
'manufacturer_id' => $this->createValidManufacturer('apple')->id,
'company_id' => $this->createValidCompany()->id,
diff --git a/tests/unit/CustomFieldTest.php b/tests/unit/CustomFieldTest.php
index 345e833fbb..33fbae5db7 100644
--- a/tests/unit/CustomFieldTest.php
+++ b/tests/unit/CustomFieldTest.php
@@ -21,7 +21,7 @@ class CustomFieldTest extends BaseTest
public function testFormat()
{
- $customfield = factory(CustomField::class)->make(['format' => 'IP']);
+ $customfield = CustomField::factory()->make(['format' => 'IP']);
$values = [
'name' => $customfield->name,
'format' => $customfield->format,
diff --git a/tests/unit/DepreciationTest.php b/tests/unit/DepreciationTest.php
index 4e1732ec38..69dccb5ce9 100644
--- a/tests/unit/DepreciationTest.php
+++ b/tests/unit/DepreciationTest.php
@@ -32,7 +32,7 @@ class DepreciationTest extends BaseTest
{
$this->createValidAssetModel();
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
- $models = factory(App\Models\AssetModel::class, 5)->states('mbp-13-model')->create(['depreciation_id'=>$depreciation->id]);
+ $models = \App\Models\AssetModel::factory()->count(5)->mbp13Model()->create(['depreciation_id'=>$depreciation->id]);
$this->assertEquals(5, $depreciation->models->count());
}
@@ -40,7 +40,7 @@ class DepreciationTest extends BaseTest
{
$category = $this->createValidCategory('license-graphics-category');
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
- $licenses = factory(App\Models\License::class, 5)->states('photoshop')->create([
+ $licenses = \App\Models\License::factory()->count(5)->photoshop()->create([
'depreciation_id'=>$depreciation->id,
'category_id' => $category->id,
]);
diff --git a/tests/unit/ImporterTest.php b/tests/unit/ImporterTest.php
index f0a3c51098..b0cb05f6ee 100644
--- a/tests/unit/ImporterTest.php
+++ b/tests/unit/ImporterTest.php
@@ -205,21 +205,21 @@ Bonnie Nelson,[email protected],bnelson0,eget nunc donec quis,quam,massa id,Li
EOT;
// Need to do this manually...
- $customField = factory(App\Models\CustomField::class)->create(['name' => 'Weight']);
- $customFieldSet = factory(App\Models\CustomFieldset::class)->create(['name' => 'Default']);
+ $customField = \App\Models\CustomField::factory()->create(['name' => 'Weight']);
+ $customFieldSet = \App\Models\CustomFieldset::factory()->create(['name' => 'Default']);
$customFieldSet->fields()->attach($customField, [
'required' => false,
'order' => 'asc', ]);
- factory(App\Models\Category::class)->states('asset-laptop-category')->create([
+ \App\Models\Category::factory()->assetLaptopCategory()->create([
'name' => 'quam',
]);
- factory(App\Models\Manufacturer::class)->states('apple')->create([
+ \App\Models\Manufacturer::factory()->apple()->create([
'name' => 'Linkbridge',
]);
- $am = factory(App\Models\AssetModel::class)->create([
+ $am = \App\Models\AssetModel::factory()->create([
'name' => 'massa id',
'fieldset_id' => $customFieldSet->id,
'category_id' => 1,
@@ -246,13 +246,13 @@ EOT;
public function initializeCustomFields()
{
- $customField = factory(App\Models\CustomField::class)->create(['name' => 'Weight']);
- $customFieldSet = factory(App\Models\CustomFieldset::class)->create(['name' => 'Default']);
+ $customField = \App\Models\CustomField::factory()->create(['name' => 'Weight']);
+ $customFieldSet = \App\Models\CustomFieldset::factory()->create(['name' => 'Default']);
$customFieldSet->fields()->attach($customField, [
'required' => false,
'order' => 'asc', ]);
- $am = factory(App\Models\AssetModel::class)->create([
+ $am = \App\Models\AssetModel::factory()->create([
'name' => 'massa id',
'fieldset_id' => $customFieldSet->id,
]);
diff --git a/tests/unit/LocationTest.php b/tests/unit/LocationTest.php
index e1675b23f5..2bb330cb49 100644
--- a/tests/unit/LocationTest.php
+++ b/tests/unit/LocationTest.php
@@ -17,7 +17,7 @@ class LocationTest extends BaseTest
{
$this->createValidLocation(['id' => 10]);
- $a = factory(Location::class)->make([
+ $a = Location::factory()->make([
'name' => 'Test Location',
'id' => 1,
'parent_id' => 10,
@@ -28,7 +28,7 @@ class LocationTest extends BaseTest
public function testFailsIfSelfParent()
{
- $a = factory(Location::class)->make([
+ $a = Location::factory()->make([
'name' => 'Test Location',
'id' => 1,
'parent_id' => 1,
diff --git a/tests/unit/NotificationTest.php b/tests/unit/NotificationTest.php
index 16fb185c9f..72d815b498 100644
--- a/tests/unit/NotificationTest.php
+++ b/tests/unit/NotificationTest.php
@@ -22,7 +22,7 @@ class NotificationTest extends BaseTest
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
{
- $admin = factory(User::class)->states('superuser')->create();
+ $admin = User::factory()->superuser()->create();
Auth::login($admin);
$cat = $this->createValidCategory('asset-laptop-category', ['require_acceptance' => true]);
$model = $this->createValidAssetModel('mbp-13-model', ['category_id' => $cat->id]);
diff --git a/tests/unit/PermissionsTest.php b/tests/unit/PermissionsTest.php
index fa7ac3e081..8c7d3a101f 100644
--- a/tests/unit/PermissionsTest.php
+++ b/tests/unit/PermissionsTest.php
@@ -72,7 +72,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_no_permissions_sees_nothing()
{
- $u = factory(App\Models\User::class)->create();
+ $u = \App\Models\User::factory()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
// $permissions = $this->noHardware;
$this->hitRoutes($permissions, $u);
@@ -83,7 +83,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_asset_permissions_can_view_assets()
{
- $u = factory(App\Models\User::class)->states('view-assets')->create();
+ $u = \App\Models\User::factory()->viewAssets()->create();
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -100,7 +100,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_asset_permissions_can_create_assets()
{
- $u = factory(App\Models\User::class)->states('create-assets')->create();
+ $u = \App\Models\User::factory()->createAssets()->create();
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -117,7 +117,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_assets_permissions_can_edit_assets()
{
- $u = factory(App\Models\User::class)->states('edit-assets')->create();
+ $u = \App\Models\User::factory()->editAssets()->create();
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -135,7 +135,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_assets_permissions_can_delete_assets()
{
- $u = factory(App\Models\User::class)->states('delete-assets')->create();
+ $u = \App\Models\User::factory()->deleteAssets()->create();
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
'assets.view' => false,
@@ -151,7 +151,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_licenses_permissions_can_view_licenses()
{
- $u = factory(App\Models\User::class)->states('view-licenses')->create();
+ $u = \App\Models\User::factory()->viewLicenses()->create();
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -168,7 +168,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_licenses_permissions_can_create_licenses()
{
- $u = factory(App\Models\User::class)->states('create-licenses')->create();
+ $u = \App\Models\User::factory()->createLicenses()->create();
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -185,7 +185,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_licenses_permissions_can_edit_licenses()
{
- $u = factory(App\Models\User::class)->states('edit-licenses')->create();
+ $u = \App\Models\User::factory()->editLicenses()->create();
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -202,7 +202,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_licenses_permissions_can_delete_licenses()
{
- $u = factory(App\Models\User::class)->states('delete-licenses')->create();
+ $u = \App\Models\User::factory()->deleteLicenses()->create();
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -219,7 +219,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_accessories_permissions_can_view_accessories()
{
- $u = factory(App\Models\User::class)->states('view-accessories')->create();
+ $u = \App\Models\User::factory()->viewAccessories()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -237,7 +237,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_accessories_permissions_can_create_accessories()
{
- $u = factory(App\Models\User::class)->states('create-accessories')->create();
+ $u = \App\Models\User::factory()->createAccessories()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -255,7 +255,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_accessories_permissions_can_edit_accessories()
{
- $u = factory(App\Models\User::class)->states('edit-accessories')->create();
+ $u = \App\Models\User::factory()->editAccessories()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -273,7 +273,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_accessories_permissions_can_delete_accessories()
{
- $u = factory(App\Models\User::class)->states('delete-accessories')->create();
+ $u = \App\Models\User::factory()->deleteAccessories()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -291,7 +291,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_consumables_permissions_can_view_consumables()
{
- $u = factory(App\Models\User::class)->states('view-consumables')->create();
+ $u = \App\Models\User::factory()->viewConsumables()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
@@ -309,7 +309,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_consumables_permissions_can_create_consumables()
{
- $u = factory(App\Models\User::class)->states('create-consumables')->create();
+ $u = \App\Models\User::factory()->createConsumables()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
@@ -327,7 +327,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_consumables_permissions_can_edit_consumables()
{
- $u = factory(App\Models\User::class)->states('edit-consumables')->create();
+ $u = \App\Models\User::factory()->editConsumables()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
@@ -345,7 +345,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_consumables_permissions_can_delete_consumables()
{
- $u = factory(App\Models\User::class)->states('delete-consumables')->create();
+ $u = \App\Models\User::factory()->deleteConsumables()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
@@ -363,7 +363,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_users_permissions_can_view_users()
{
- $u = factory(App\Models\User::class)->states('view-users')->create();
+ $u = \App\Models\User::factory()->viewUsers()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents;
@@ -381,7 +381,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_users_permissions_can_create_users()
{
- $u = factory(App\Models\User::class)->states('create-users')->create();
+ $u = \App\Models\User::factory()->createUsers()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents;
@@ -399,7 +399,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_users_permissions_can_edit_users()
{
- $u = factory(App\Models\User::class)->states('edit-users')->create();
+ $u = \App\Models\User::factory()->editUsers()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents;
@@ -417,7 +417,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_users_permissions_can_delete_users()
{
- $u = factory(App\Models\User::class)->states('delete-users')->create();
+ $u = \App\Models\User::factory()->deleteUsers()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents;
@@ -435,7 +435,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_view_components_permissions_can_view_components()
{
- $u = factory(App\Models\User::class)->states('view-components')->create();
+ $u = \App\Models\User::factory()->viewComponents()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noUsers;
@@ -453,7 +453,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_create_components_permissions_can_create_components()
{
- $u = factory(App\Models\User::class)->states('create-components')->create();
+ $u = \App\Models\User::factory()->createComponents()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noUsers;
$permissions = array_merge($permissions, [
@@ -470,7 +470,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_edit_components_permissions_can_edit_components()
{
- $u = factory(App\Models\User::class)->states('edit-components')->create();
+ $u = \App\Models\User::factory()->editComponents()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noUsers;
@@ -488,7 +488,7 @@ class PermissionsTest extends BaseTest
*/
public function a_user_with_delete_components_permissions_can_delete_components()
{
- $u = factory(App\Models\User::class)->states('delete-components')->create();
+ $u = \App\Models\User::factory()->deleteComponents()->create();
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noUsers;
diff --git a/tests/unit/StatuslabelTest.php b/tests/unit/StatuslabelTest.php
index e953b6b861..6cbc582235 100644
--- a/tests/unit/StatuslabelTest.php
+++ b/tests/unit/StatuslabelTest.php
@@ -15,7 +15,7 @@ class StatuslabelTest extends BaseTest
public function testRTDStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('rtd')->make();
+ $statuslabel = Statuslabel::factory()->rtd()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -30,7 +30,7 @@ class StatuslabelTest extends BaseTest
public function testPendingStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('pending')->make();
+ $statuslabel = Statuslabel::factory()->pending()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -44,7 +44,7 @@ class StatuslabelTest extends BaseTest
public function testArchivedStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('archived')->make();
+ $statuslabel = Statuslabel::factory()->archived()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -58,7 +58,7 @@ class StatuslabelTest extends BaseTest
public function testOutForRepairStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('out_for_repair')->make();
+ $statuslabel = Statuslabel::factory()->outForRepair()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -72,7 +72,7 @@ class StatuslabelTest extends BaseTest
public function testOutForDiagnosticsStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('out_for_diagnostics')->make();
+ $statuslabel = Statuslabel::factory()->outForDiagnostics()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -86,7 +86,7 @@ class StatuslabelTest extends BaseTest
public function testBrokenStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('broken')->make();
+ $statuslabel = Statuslabel::factory()->broken()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
@@ -100,7 +100,7 @@ class StatuslabelTest extends BaseTest
public function testLostStatuslabelAdd()
{
- $statuslabel = factory(Statuslabel::class)->states('lost')->make();
+ $statuslabel = Statuslabel::factory()->lost()->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,