63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Student;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Entry>
|
|
*/
|
|
class EntryFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'student_id' => Student::factory(),
|
|
'audition_id' => Audition::factory(),
|
|
'draw_number' => null,
|
|
'for_seating' => 1,
|
|
'for_advancement' => 1,
|
|
|
|
];
|
|
}
|
|
|
|
public function seatingOnly(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['for_advancement' => 0]
|
|
);
|
|
}
|
|
|
|
public function advanceOnly(): self
|
|
{
|
|
return $this->state(
|
|
fn (array $attributes) => ['for_seating' => 0]
|
|
);
|
|
}
|
|
|
|
public function forStudent(Student $student): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($student) {
|
|
return [
|
|
'student_id' => $student->id,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function forAudition(Audition $audition): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($audition) {
|
|
return [
|
|
'audition_id' => $audition->id,
|
|
];
|
|
});
|
|
}
|
|
}
|