mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
added asset_eol_date and explicit to factory
This commit is contained in:
parent
78c400e948
commit
1b18cd7fe6
|
@ -129,7 +129,8 @@ class AssetObserver
|
|||
}
|
||||
|
||||
//determine if explicit and set eol_explit to true
|
||||
if(!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) || ($asset->isDirty($asset->asset_eol_date) || $asset->isDirty($asset->purchase_date))) {
|
||||
//conditions might need more work
|
||||
if(!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date)) {
|
||||
if($asset->model->eol) {
|
||||
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
|
||||
if($months != $asset->model->eol) {
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Models\Location;
|
|||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class AssetFactory extends Factory
|
||||
|
@ -48,6 +49,17 @@ class AssetFactory extends Factory
|
|||
'last_checkout' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterMaking(function (Asset $asset) {
|
||||
// $asset->asset_eol_date = Carbon::parse($asset->purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
$asset->asset_eol_date = $this->faker->boolean(5)
|
||||
? Carbon::parse($asset->purchase_date)->addMonths(rand(0, 20))->format('Y-m-d')
|
||||
: Carbon::parse($asset->purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
});
|
||||
}
|
||||
|
||||
public function laptopMbp()
|
||||
{
|
||||
|
@ -338,4 +350,5 @@ class AssetFactory extends Factory
|
|||
{
|
||||
return $this->state(['requestable' => false]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue