108 lines
2.2 KiB
PHP
Raw Normal View History

2020-01-12 21:43:54 +03:00
<?php
2020-10-14 17:07:59 +03:00
namespace Database\Factories;
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
use App\Abstracts\Factory;
use App\Models\Setting\Category as Model;
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
class Category extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Model::class;
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$types = ['income', 'expense', 'item', 'other'];
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'type' => $this->faker->randomElement($types),
'color' => $this->faker->hexColor,
'enabled' => $this->faker->boolean ? 1 : 0,
2021-09-10 00:31:39 +03:00
'created_from' => 'core::factory',
2020-10-14 17:07:59 +03:00
];
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model is enabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function enabled()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'enabled' => 1,
]);
2020-10-14 17:07:59 +03:00
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model is disabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function disabled()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'enabled' => 0,
]);
2020-10-14 17:07:59 +03:00
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model type is income.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function income()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'type' => 'income',
]);
2020-10-14 17:07:59 +03:00
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model type is expense.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function expense()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'type' => 'expense',
]);
2020-10-14 17:07:59 +03:00
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model type is item.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function item()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'type' => 'item',
]);
2020-10-14 17:07:59 +03:00
}
2020-01-12 21:43:54 +03:00
2020-10-14 17:07:59 +03:00
/**
* Indicate that the model type is other.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function other()
{
2020-10-15 00:08:41 +03:00
return $this->state([
'type' => 'other',
]);
2020-10-14 17:07:59 +03:00
}
}