2017-06-12 17:39:03 -07:00
|
|
|
<?php
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
2017-06-12 17:39:03 -07:00
|
|
|
use App\Models\Asset;
|
2017-08-31 11:14:21 -07:00
|
|
|
use App\Models\AssetModel;
|
|
|
|
use App\Models\Category;
|
2021-06-10 13:19:27 -07:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2017-06-12 17:39:03 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Model Factories
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Factories related exclusively to modelling assets.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2017-10-07 05:32:22 -07:00
|
|
|
// These are just for unit tests, not to generate data
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
class AssetFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = Asset::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'name' => null,
|
|
|
|
'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),
|
|
|
|
'requestable' => $this->faker->boolean(),
|
|
|
|
'assigned_to' => null,
|
|
|
|
'assigned_type' => null,
|
|
|
|
'next_audit_date' => null,
|
|
|
|
'last_checkout' => null,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopMbp()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopMbpPending()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
'status_id' => 2,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopMbpArchived()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
'status_id' => 3,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopAir()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 2,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopSurface()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 3,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopXps()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 4,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopSpectre()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 5,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopZenbook()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 6,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopYoga()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 7,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopMacpro()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 8,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopLenovoI5()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 9,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopOptiplex()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 10,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confPolycom()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 11,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confPolycomcx()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 12,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tabletIpad()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 13,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tabletTab3()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 14,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:12:27 -07:00
|
|
|
public function phoneIphone11()
|
2021-06-10 13:17:44 -07:00
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 15,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:12:27 -07:00
|
|
|
public function phoneIphone12()
|
2021-06-10 13:17:44 -07:00
|
|
|
{
|
|
|
|
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,
|
2021-06-11 19:41:20 -07:00
|
|
|
'assigned_type' => \App\Models\User::class,
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assignedToLocation()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
'assigned_to' => \App\Models\Location::factory()->create()->id,
|
2021-06-11 19:41:20 -07:00
|
|
|
'assigned_type' => \App\Models\Location::class,
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assignedToAsset()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
'assigned_to' => \App\Models\Asset::factory()->create()->id,
|
2021-06-11 19:41:20 -07:00
|
|
|
'assigned_type' => \App\Models\Asset::class,
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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(),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|