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;
|
2021-12-02 16:14:45 -08:00
|
|
|
use App\Models\Location;
|
2023-03-14 13:24:50 -07:00
|
|
|
use App\Models\Statuslabel;
|
2021-12-02 16:14:45 -08:00
|
|
|
use App\Models\Supplier;
|
2023-03-14 11:34:58 -07:00
|
|
|
use App\Models\User;
|
2021-06-10 13:19:27 -07:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2017-06-12 17:39:03 -07:00
|
|
|
|
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,
|
2023-03-16 17:08:18 -07:00
|
|
|
'model_id' => AssetModel::factory(),
|
2023-02-07 16:17:05 -08:00
|
|
|
'rtd_location_id' => Location::factory(),
|
2023-03-02 13:41:52 -08:00
|
|
|
'serial' => $this->faker->uuid(),
|
2023-03-14 13:24:50 -07:00
|
|
|
'status_id' => function () {
|
|
|
|
return Statuslabel::where('name', 'Ready to Deploy')->first() ?? Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
|
|
|
|
},
|
2023-03-20 11:19:34 -07:00
|
|
|
'user_id' => User::factory()->superuser(),
|
2021-06-10 13:17:44 -07:00
|
|
|
'asset_tag' => $this->faker->unixTime('now'),
|
|
|
|
'notes' => 'Created by DB seeder',
|
2023-02-23 13:39:05 -08:00
|
|
|
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
|
2021-06-10 13:17:44 -07:00
|
|
|
'purchase_cost' => $this->faker->randomFloat(2, '299.99', '2999.99'),
|
|
|
|
'order_number' => $this->faker->numberBetween(1000000, 50000000),
|
2023-02-07 16:17:05 -08:00
|
|
|
'supplier_id' => Supplier::factory(),
|
2021-06-10 13:17:44 -07:00
|
|
|
'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 [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopMbpPending()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
|
|
|
|
},
|
2023-03-14 13:24:50 -07:00
|
|
|
'status_id' => function () {
|
|
|
|
return Statuslabel::where('name', 'Pending')->first() ?? Statuslabel::factory()->pending()->make(['name' => 'Pending']);
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopMbpArchived()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
|
|
|
|
},
|
2023-03-14 13:24:50 -07:00
|
|
|
'status_id' => function () {
|
|
|
|
return Statuslabel::where('name', 'Archived')->first() ?? Statuslabel::factory()->archived()->make(['name' => 'Archived']);
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopAir()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Air')->first() ?? AssetModel::factory()->mbpAirModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopSurface()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Surface')->first() ?? AssetModel::factory()->surfaceModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopXps()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'XPS 13')->first() ?? AssetModel::factory()->xps13Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopSpectre()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Spectre')->first() ?? AssetModel::factory()->spectreModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopZenbook()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'ZenBook UX310')->first() ?? AssetModel::factory()->zenbookModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function laptopYoga()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Yoga 910')->first() ?? AssetModel::factory()->yogaModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopMacpro()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'iMac Pro')->first() ?? AssetModel::factory()->macproModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopLenovoI5()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Lenovo Intel Core i5')->first() ?? AssetModel::factory()->lenovoI5Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desktopOptiplex()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'OptiPlex')->first() ?? AssetModel::factory()->optiplexModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confPolycom()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'SoundStation 2')->first() ?? AssetModel::factory()->polycomModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confPolycomcx()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Polycom CX3000 IP Conference Phone')->first() ?? AssetModel::factory()->polycomcxModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tabletIpad()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'iPad Pro')->first() ?? AssetModel::factory()->ipadModel();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tabletTab3()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Tab3')->first() ?? AssetModel::factory()->tab3Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:12:27 -07:00
|
|
|
public function phoneIphone11()
|
2021-06-10 13:17:44 -07:00
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'iPhone 11')->first() ?? AssetModel::factory()->iphone11Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:12:27 -07:00
|
|
|
public function phoneIphone12()
|
2021-06-10 13:17:44 -07:00
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'iPhone 12')->first() ?? AssetModel::factory()->iphone12Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ultrafine()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Ultrafine 4k')->first() ?? AssetModel::factory()->ultrafine();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ultrasharp()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Ultrasharp U2415')->first() ?? AssetModel::factory()->ultrasharp();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-21 09:54:55 -07:00
|
|
|
public function assignedToUser()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'assigned_to' => User::factory(),
|
|
|
|
'assigned_type' => User::class,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assignedToLocation()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'assigned_to' => Location::factory(),
|
|
|
|
'assigned_type' => Location::class,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assignedToAsset()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'model_id' => 1,
|
|
|
|
'assigned_to' => Asset::factory(),
|
|
|
|
'assigned_type' => Asset::class,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function requiresAcceptance()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deleted()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
2023-03-14 13:56:25 -07:00
|
|
|
'model_id' => function () {
|
|
|
|
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
'deleted_at' => $this->faker->dateTime(),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2023-06-22 12:36:43 -07:00
|
|
|
|
|
|
|
public function requestable()
|
|
|
|
{
|
|
|
|
return $this->state(['requestable' => true]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function nonrequestable()
|
|
|
|
{
|
|
|
|
return $this->state(['requestable' => false]);
|
|
|
|
}
|
2021-06-10 13:17:44 -07:00
|
|
|
}
|