buckets/database/factories/OutflowFactory.php

41 lines
966 B
PHP
Raw Normal View History

2025-12-31 01:56:50 +01:00
<?php
namespace Database\Factories;
use App\Models\Bucket;
use App\Models\Outflow;
use App\Models\Stream;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Outflow>
*/
class OutflowFactory extends Factory
{
public function definition(): array
{
return [
'stream_id' => null,
'bucket_id' => null,
'amount' => $this->faker->numberBetween(2500, 100000), // $25 to $1000 in cents
'date' => $this->faker->dateTimeBetween('-6 months', 'now'),
'description' => $this->faker->sentence(),
'is_projected' => $this->faker->boolean(),
];
}
public function stream(Stream $stream): self
{
return $this->state(fn () => [
'stream_id' => $stream->id,
]);
}
public function bucket(Bucket $bucket): self
{
return $this->state(fn () => [
'bucket_id' => $bucket->id,
]);
}
}