Shift to class based factories

This commit is contained in:
Laravel Shift 2021-06-10 20:17:44 +00:00
parent c02a95e73f
commit 104b441e0d
105 changed files with 2713 additions and 1618 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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'];

View file

@ -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

View file

@ -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

View file

@ -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 = [

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
/**

View file

@ -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;

View file

@ -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';

View file

@ -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;

View file

@ -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;
$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),
];
});
/**
* 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-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 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-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 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, '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 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),
];
});
}
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,
];
});
}
}

View file

@ -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!',
];
}
}

View file

@ -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,
];
});
class AssetFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Asset::class;
$factory->state(Asset::class, 'requires-acceptance', function ($faker) {
return [
'model_id' => 1,
];
});
/**
* 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,
];
}
$factory->state(Asset::class, 'deleted', function ($faker) {
return [
'model_id' => 1,
'deleted_at' => $faker->dateTime(),
];
});
public function laptopMbp()
{
return $this->state(function () {
return [
'model_id' => 1,
];
});
}
$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(),
];
});
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(),
];
});
}
}

View file

@ -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(),
];
}
}

View file

@ -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',
];
});
class AssetModelFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\AssetModel::class;
$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',
];
});
/**
* 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',
];
});
}
}

View file

@ -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,
];
});
class CategoryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\Category::class;
$factory->state(App\Models\Category::class, 'asset-laptop-category', function ($faker) {
return [
'name' => 'Laptops',
'category_type' => 'asset',
'require_acceptance' => true,
];
});
/**
* 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,
];
}
$factory->state(App\Models\Category::class, 'asset-desktop-category', function ($faker) {
return [
'name' => 'Desktops',
'category_type' => 'asset',
];
});
public function assetLaptopCategory()
{
return $this->state(function () {
return [
'name' => 'Laptops',
'category_type' => 'asset',
'require_acceptance' => true,
];
});
}
$factory->state(App\Models\Category::class, 'asset-display-category', function ($faker) {
return [
'name' => 'Displays',
'category_type' => 'asset',
];
});
public function assetDesktopCategory()
{
return $this->state(function () {
return [
'name' => 'Desktops',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'asset-tablet-category', function ($faker) {
return [
'name' => 'Tablets',
'category_type' => 'asset',
];
});
public function assetDisplayCategory()
{
return $this->state(function () {
return [
'name' => 'Displays',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'asset-mobile-category', function ($faker) {
return [
'name' => 'Mobile Phones',
'category_type' => 'asset',
];
});
public function assetTabletCategory()
{
return $this->state(function () {
return [
'name' => 'Tablets',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'asset-conference-category', function ($faker) {
return [
'name' => 'Conference Phones',
'category_type' => 'asset',
];
});
public function assetMobileCategory()
{
return $this->state(function () {
return [
'name' => 'Mobile Phones',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'asset-voip-category', function ($faker) {
return [
'name' => 'VOIP Phones',
'category_type' => 'asset',
];
});
public function assetConferenceCategory()
{
return $this->state(function () {
return [
'name' => 'Conference Phones',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'accessory-keyboard-category', function ($faker) {
return [
'name' => 'Keyboards',
'category_type' => 'accessory',
];
});
public function assetVoipCategory()
{
return $this->state(function () {
return [
'name' => 'VOIP Phones',
'category_type' => 'asset',
];
});
}
$factory->state(App\Models\Category::class, 'accessory-mouse-category', function ($faker) {
return [
'name' => 'Mouse',
'category_type' => 'accessory',
];
});
public function accessoryKeyboardCategory()
{
return $this->state(function () {
return [
'name' => 'Keyboards',
'category_type' => 'accessory',
];
});
}
$factory->state(App\Models\Category::class, 'component-hdd-category', function ($faker) {
return [
'name' => 'HDD/SSD',
'category_type' => 'component',
];
});
public function accessoryMouseCategory()
{
return $this->state(function () {
return [
'name' => 'Mouse',
'category_type' => 'accessory',
];
});
}
$factory->state(App\Models\Category::class, 'component-ram-category', function ($faker) {
return [
'name' => 'RAM',
'category_type' => 'component',
];
});
public function componentHddCategory()
{
return $this->state(function () {
return [
'name' => 'HDD/SSD',
'category_type' => 'component',
];
});
}
$factory->state(App\Models\Category::class, 'consumable-paper-category', function ($faker) {
return [
'name' => 'Printer Paper',
'category_type' => 'consumable',
];
});
public function componentRamCategory()
{
return $this->state(function () {
return [
'name' => 'RAM',
'category_type' => 'component',
];
});
}
$factory->state(App\Models\Category::class, 'consumable-ink-category', function ($faker) {
return [
'name' => 'Printer Ink',
'category_type' => 'consumable',
];
});
public function consumablePaperCategory()
{
return $this->state(function () {
return [
'name' => 'Printer Paper',
'category_type' => 'consumable',
];
});
}
$factory->state(App\Models\Category::class, 'license-graphics-category', function ($faker) {
return [
'name' => 'Graphics Software',
'category_type' => 'license',
];
});
public function consumableInkCategory()
{
return $this->state(function () {
return [
'name' => 'Printer Ink',
'category_type' => 'consumable',
];
});
}
$factory->state(App\Models\Category::class, 'license-office-category', function ($faker) {
return [
'name' => 'Office Software',
'category_type' => 'license',
];
});
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',
];
});
}
}

View file

@ -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,
];
}
}

View file

@ -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;
},
];
}
}

View file

@ -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,
];
});

View file

@ -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;
$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,
];
});
/**
* 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, 'paper', function ($faker) {
return [
'name' => 'Laserjet Paper (Ream)',
'category_id' => 10,
'manufacturer_id' => 10,
'qty' => 20,
'min_amt' => 2,
];
});
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, 'ink', function ($faker) {
return [
'name' => 'Laserjet Toner (black)',
'category_id' => 11,
'manufacturer_id' => 5,
'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,
];
});
}
public function ink()
{
return $this->state(function () {
return [
'name' => 'Laserjet Toner (black)',
'category_id' => 11,
'manufacturer_id' => 5,
'qty' => 20,
'min_amt' => 2,
];
});
}
}

View file

@ -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}$/',
];
});
}
}

View file

@ -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}$/',
];
});

View file

@ -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',
];
});
}
}

View file

@ -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',
];
});
}
}

View file

@ -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',
];
});

View file

@ -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;
$factory->state(App\Models\Depreciation::class, 'computer', function ($faker) {
return [
'name' => 'Computer Depreciation',
'months' => 36,
];
});
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'user_id' => 1,
];
}
$factory->state(App\Models\Depreciation::class, 'display', function ($faker) {
return [
'name' => 'Display Depreciation',
'months' => 12,
];
});
public function computer()
{
return $this->state(function () {
return [
'name' => 'Computer Depreciation',
'months' => 36,
];
});
}
$factory->state(App\Models\Depreciation::class, 'mobile-phones', function ($faker) {
return [
'name' => 'Mobile Phone Depreciation',
'months' => 24,
];
});
public function display()
{
return $this->state(function () {
return [
'name' => 'Display Depreciation',
'months' => 12,
];
});
}
public function mobilePhones()
{
return $this->state(function () {
return [
'name' => 'Mobile Phone Depreciation',
'months' => 24,
];
});
}
}

View file

@ -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,
];
}
}

View file

@ -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;
});
}
}

View file

@ -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',
];
}
}

View file

@ -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',
];
});
}
}

View file

@ -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',
];
});

View file

@ -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',
];
}
}

View file

@ -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,
];
});

View file

@ -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,
];
});
}
}

View file

@ -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.
];
}
}

View file

@ -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' => 'snipe@snipe.net',
'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"}',
];
});
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\User::class;
$factory->state(App\Models\User::class, 'edit-users', function ($faker) {
return [
'permissions' => '{"users.edit":"1"}',
];
});
/**
* 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,
];
}
$factory->state(App\Models\User::class, 'delete-users', function ($faker) {
return [
'permissions' => '{"users.delete":"1"}',
];
});
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' => 'snipe@snipe.net',
'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"}',
];
});
}
}

View file

@ -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'.'/';

View file

@ -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();
}
}

View file

@ -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'.'/';

View file

@ -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();
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();
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();
Asset::factory()->count(30)->desktopMacpro()->create();
Asset::factory()->count(30)->desktopLenovoI5()->create();
Asset::factory()->count(30)->desktopOptiplex()->create();
factory(Asset::class, 5)->states('conf-polycom')->create();
factory(Asset::class, 2)->states('conf-polycomcx')->create();
Asset::factory()->count(5)->confPolycom()->create();
Asset::factory()->count(2)->confPolycomcx()->create();
factory(Asset::class, 12)->states('tablet-ipad')->create();
factory(Asset::class, 4)->states('tablet-tab3')->create();
Asset::factory()->count(12)->tabletIpad()->create();
Asset::factory()->count(4)->tabletTab3()->create();
factory(Asset::class, 27)->states('phone-iphone6s')->create();
factory(Asset::class, 40)->states('phone-iphone7')->create();
Asset::factory()->count(27)->phoneIphone6s()->create();
Asset::factory()->count(40)->phoneIphone7()->create();
factory(Asset::class, 10)->states('ultrafine')->create();
factory(Asset::class, 10)->states('ultrasharp')->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

View file

@ -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
}
}

View file

@ -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'.'/';

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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([
[

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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();
}
}

View file

@ -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'.'/';

View file

@ -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'.'/';

View file

@ -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();
}
}

View file

@ -8,6 +8,6 @@ class SupplierSeeder extends Seeder
public function run()
{
Supplier::truncate();
factory(Supplier::class, 5)->create();
Supplier::factory()->count(5)->create();
}
}

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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 = [

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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);
}

View file

@ -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,

View file

@ -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()]);

View file

@ -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,
];

View file

@ -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',
]);

View file

@ -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,
]);

View file

@ -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 = [

View file

@ -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,
]);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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',

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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,

View file

@ -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());
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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,

View file

@ -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,

View file

@ -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,
]);

Some files were not shown because too many files have changed in this diff Show more