65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\ScoringGuide;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\SubscoreDefinition>
|
|
*/
|
|
class SubscoreDefinitionFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
|
|
return [
|
|
'scoring_guide_id' => function (array $attributes) {
|
|
return array_key_exists('scoring_guide_id', $attributes)
|
|
? $attributes['scoring_guide_id']
|
|
: ScoringGuide::factory()->create()->id;
|
|
},
|
|
'name' => $this->faker->word,
|
|
'max_score' => 100,
|
|
'weight' => $this->faker->numberBetween(1, 4),
|
|
'display_order' => $this->faker->numberBetween(1, 20),
|
|
'tiebreak_order' => $this->faker->numberBetween(1, 20),
|
|
'for_seating' => 1,
|
|
'for_advance' => 1,
|
|
];
|
|
}
|
|
|
|
public function seatingOnly(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['for_advance' => 0]
|
|
);
|
|
}
|
|
|
|
public function advanceOnly(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['for_seating' => 0]
|
|
);
|
|
}
|
|
|
|
public function displayFirst(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['display_order' => 0]
|
|
);
|
|
}
|
|
|
|
public function tiebreakFirst(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['tiebreak_order' => 0]
|
|
);
|
|
}
|
|
}
|