36 lines
915 B
PHP
36 lines
915 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Modules\CustomField\Models\CustomFieldDefinition;
|
||
|
|
use App\Modules\CustomField\Models\CustomFieldType;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class CustomFieldDefinitionFactory extends Factory
|
||
|
|
{
|
||
|
|
protected $model = CustomFieldDefinition::class;
|
||
|
|
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
$label = $this->faker->unique()->words(2, true);
|
||
|
|
|
||
|
|
return [
|
||
|
|
'label' => ucfirst($label),
|
||
|
|
'key' => Str::slug($label, '_'),
|
||
|
|
'type' => CustomFieldType::Text->value,
|
||
|
|
'options' => null,
|
||
|
|
'is_required' => false,
|
||
|
|
'sort_order' => 0,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function select(array $options): static
|
||
|
|
{
|
||
|
|
return $this->state(fn () => [
|
||
|
|
'type' => CustomFieldType::Select->value,
|
||
|
|
'options' => $options,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|