- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya - memperbaiki enum di migrasi
41 lines
987 B
PHP
41 lines
987 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ExpenseType;
|
|
use App\Models\Expense;
|
|
use App\Models\Outlet;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class ExpenseFactory extends Factory
|
|
{
|
|
protected $model = Expense::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'outlet_id' => Outlet::factory(),
|
|
'amount' => $this->faker->numberBetween(10000, 200000),
|
|
'description' => $this->faker->sentence(6),
|
|
'type' => ExpenseType::OPERATIONAL,
|
|
];
|
|
}
|
|
|
|
public function operational(): Factory
|
|
{
|
|
return $this->state(fn () => ['type' => ExpenseType::OPERATIONAL]);
|
|
}
|
|
|
|
public function purchase(): Factory
|
|
{
|
|
return $this->state(fn () => ['type' => ExpenseType::PURCHASE]);
|
|
}
|
|
|
|
public function salary(): Factory
|
|
{
|
|
return $this->state(fn () => ['type' => ExpenseType::SALARY]);
|
|
}
|
|
}
|