diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php index 43845c3075..8f910b903d 100644 --- a/database/factories/AssetFactory.php +++ b/database/factories/AssetFactory.php @@ -300,11 +300,11 @@ class AssetFactory extends Factory }); } - public function assignedToLocation() + public function assignedToLocation(Location $location = null) { - return $this->state(function () { + return $this->state(function () use ($location) { return [ - 'assigned_to' => Location::factory(), + 'assigned_to' => $location->id ?? Location::factory(), 'assigned_type' => Location::class, ]; }); diff --git a/database/factories/LocationFactory.php b/database/factories/LocationFactory.php index 6db268e8c1..abd773010e 100644 --- a/database/factories/LocationFactory.php +++ b/database/factories/LocationFactory.php @@ -25,4 +25,13 @@ class LocationFactory extends Factory 'image' => rand(1, 9).'.jpg', ]; } + + public function deletedLocation() + { + return $this->state(function () { + return [ + 'deleted_at' => $this->faker->dateTime(), + ]; + }); + } }