buckets/database/factories/OutflowFactory.php

40 lines
966 B
PHP

<?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,
]);
}
}