38 lines
902 B
PHP
38 lines
902 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\CashAccount;
|
|
use App\Models\CashTransaction;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<CashTransaction>
|
|
*/
|
|
class CashTransactionFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
$amount = fake()->numberBetween(10_000, 5_000_000);
|
|
|
|
return [
|
|
'cash_account_id' => CashAccount::factory(),
|
|
'created_by_id' => User::factory(),
|
|
'reference_type' => null,
|
|
'reference_id' => null,
|
|
'amount' => $amount,
|
|
'balance_after' => $amount,
|
|
'description' => fake()->sentence(3),
|
|
];
|
|
}
|
|
|
|
public function deposit(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'reference_type' => null,
|
|
'reference_id' => null,
|
|
]);
|
|
}
|
|
}
|