added category factory
This commit is contained in:
34
database/factories/Category.php
Normal file
34
database/factories/Category.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Setting\Category;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
|
||||
$factory->define(Category::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
$types = ['income', 'expense', 'item', 'other'];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'type' => $faker->randomElement($types),
|
||||
'color' => $faker->hexColor,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Category::class, 'enabled', ['enabled' => 1]);
|
||||
|
||||
$factory->state(Category::class, 'disabled', ['enabled' => 0]);
|
||||
|
||||
$factory->state(Category::class, 'income', ['type' => 'income']);
|
||||
|
||||
$factory->state(Category::class, 'expense', ['type' => 'expense']);
|
||||
|
||||
$factory->state(Category::class, 'item', ['type' => 'item']);
|
||||
|
||||
$factory->state(Category::class, 'other', ['type' => 'other']);
|
Reference in New Issue
Block a user