Simplify factory state

This commit is contained in:
Marcus Moore 2024-04-16 12:36:13 -07:00
parent eefe377159
commit ab561d1ce8
No known key found for this signature in database

View file

@ -355,7 +355,9 @@ class AssetFactory extends Factory
public function hasEncryptedCustomField()
{
return $this->state(['model_id' => AssetModel::where('name', 'asset with encrypted field')->first() ?? AssetModel::factory()->withEncryptedField()]);
return $this->afterMaking(function (Asset $asset) {
$asset->model_id = AssetModel::factory()->withEncryptedField()->create()->id;
});
}