mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Added checkedOutToUser factory for consumables
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4635e9269d
commit
d66d6e70a6
|
@ -7,6 +7,7 @@ use App\Models\Company;
|
||||||
use App\Models\Consumable;
|
use App\Models\Consumable;
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
|
|
||||||
|
@ -116,4 +117,16 @@ class ConsumableFactory extends Factory
|
||||||
$consumable->category->update(['require_acceptance' => 1]);
|
$consumable->category->update(['require_acceptance' => 1]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkedOutToUser(User $user = null)
|
||||||
|
{
|
||||||
|
return $this->afterCreating(function (Consumable $consumable) use ($user) {
|
||||||
|
$consumable->users()->attach($consumable->id, [
|
||||||
|
'consumable_id' => $consumable->id,
|
||||||
|
'created_at' => Carbon::now(),
|
||||||
|
'user_id' => 1,
|
||||||
|
'assigned_to' => $user->id ?? User::factory()->create()->id,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue