60 lines
1.4 KiB
PHP
Raw Normal View History

2019-11-18 10:54:26 +03:00
<?php
2020-10-14 17:07:59 +03:00
namespace Database\Factories;
2019-11-18 10:54:26 +03:00
2020-10-14 17:07:59 +03:00
use App\Abstracts\Factory;
use App\Models\Common\Item as Model;
2020-01-06 16:37:32 +03:00
2020-10-14 17:07:59 +03:00
class Item extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Model::class;
2019-11-18 10:54:26 +03:00
2020-10-14 17:07:59 +03:00
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'description' => $this->faker->text(100),
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
'sale_price' => $this->faker->randomFloat(2, 10, 20),
'category_id' => $this->company->categories()->item()->get()->random(1)->pluck('id')->first(),
'enabled' => $this->faker->boolean ? 1 : 0,
2021-09-07 10:33:34 +03:00
'created_from' => 'factory',
2020-10-14 17:07:59 +03:00
];
}
2020-01-07 01:28:05 +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-07 01:28:05 +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
}
}