96 lines
2.3 KiB
PHP
96 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
|
||
|
|
*/
|
||
|
|
class ModelFactory extends Factory
|
||
|
|
{
|
||
|
|
protected $model = Model::class;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Define the model's default state.
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'tenant_id' => 1,
|
||
|
|
'code' => 'KSS' . $this->faker->numberBetween(10, 99),
|
||
|
|
'name' => $this->faker->words(3, true),
|
||
|
|
'description' => $this->faker->sentence(),
|
||
|
|
'status' => $this->faker->randomElement(['DRAFT', 'RELEASED', 'ARCHIVED']),
|
||
|
|
'product_family' => $this->faker->randomElement(['SCREEN', 'STEEL']),
|
||
|
|
'is_active' => true,
|
||
|
|
'created_by' => 1,
|
||
|
|
'updated_by' => 1,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicate that the model is active.
|
||
|
|
*/
|
||
|
|
public function active(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'is_active' => true,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicate that the model is inactive.
|
||
|
|
*/
|
||
|
|
public function inactive(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'is_active' => false,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicate that the model is released.
|
||
|
|
*/
|
||
|
|
public function released(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'status' => 'RELEASED',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Indicate that the model is draft.
|
||
|
|
*/
|
||
|
|
public function draft(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'status' => 'DRAFT',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Screen type model.
|
||
|
|
*/
|
||
|
|
public function screen(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'product_family' => 'SCREEN',
|
||
|
|
'code' => 'KSS' . $this->faker->numberBetween(10, 99),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Steel type model.
|
||
|
|
*/
|
||
|
|
public function steel(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'product_family' => 'STEEL',
|
||
|
|
'code' => 'KST' . $this->faker->numberBetween(10, 99),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|