151 lines
4.2 KiB
PHP
151 lines
4.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\Model;
|
||
|
|
use App\Models\ModelFormula;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ModelFormula>
|
||
|
|
*/
|
||
|
|
class ModelFormulaFactory extends Factory
|
||
|
|
{
|
||
|
|
protected $model = ModelFormula::class;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Define the model's default state.
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'tenant_id' => 1,
|
||
|
|
'model_id' => Model::factory(),
|
||
|
|
'name' => $this->faker->word(),
|
||
|
|
'expression' => 'W0 * H0',
|
||
|
|
'description' => $this->faker->sentence(),
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => $this->faker->numberBetween(1, 10),
|
||
|
|
'is_active' => true,
|
||
|
|
'created_by' => 1,
|
||
|
|
'updated_by' => 1,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Screen model formulas.
|
||
|
|
*/
|
||
|
|
public function screenFormulas(): static
|
||
|
|
{
|
||
|
|
return $this->sequence(
|
||
|
|
[
|
||
|
|
'name' => 'W1',
|
||
|
|
'expression' => 'W0 + 120',
|
||
|
|
'description' => '최종 가로 크기',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'H1',
|
||
|
|
'expression' => 'H0 + 100',
|
||
|
|
'description' => '최종 세로 크기',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'area',
|
||
|
|
'expression' => 'W1 * H1 / 1000000',
|
||
|
|
'description' => '면적 (㎡)',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'weight',
|
||
|
|
'expression' => 'area * 15',
|
||
|
|
'description' => '중량 (kg)',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 4,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'motor',
|
||
|
|
'expression' => 'IF(area <= 3, "0.5HP", IF(area <= 6, "1HP", "2HP"))',
|
||
|
|
'description' => '모터 용량',
|
||
|
|
'return_type' => 'STRING',
|
||
|
|
'sort_order' => 5,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'bracket',
|
||
|
|
'expression' => 'CEIL(W1 / 600)',
|
||
|
|
'description' => '브라켓 개수',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 6,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'guide',
|
||
|
|
'expression' => 'H1 / 1000 * 2',
|
||
|
|
'description' => '가이드 길이 (m)',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 7,
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Steel model formulas.
|
||
|
|
*/
|
||
|
|
public function steelFormulas(): static
|
||
|
|
{
|
||
|
|
return $this->sequence(
|
||
|
|
[
|
||
|
|
'name' => 'W1',
|
||
|
|
'expression' => 'W0 + 50',
|
||
|
|
'description' => '최종 가로 크기',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 1,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'H1',
|
||
|
|
'expression' => 'H0 + 50',
|
||
|
|
'description' => '최종 세로 크기',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 2,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'area',
|
||
|
|
'expression' => 'W1 * H1 / 1000000',
|
||
|
|
'description' => '면적 (㎡)',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 3,
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'weight',
|
||
|
|
'expression' => 'area * thickness * 7.85',
|
||
|
|
'description' => '중량 (kg)',
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
'sort_order' => 4,
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Number type formula.
|
||
|
|
*/
|
||
|
|
public function number(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'return_type' => 'NUMBER',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* String type formula.
|
||
|
|
*/
|
||
|
|
public function string(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'return_type' => 'STRING',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|