44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\NominationEnsemble;
|
|
use App\Models\NominationEnsembleEntry;
|
|
use App\Models\Student;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class NominationEnsembleEntryFactory extends Factory
|
|
{
|
|
protected $model = NominationEnsembleEntry::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'student_id' => Student::factory(),
|
|
'nomination_ensemble_id' => NominationEnsemble::factory(),
|
|
'data' => json_encode([5, 2, 4]),
|
|
'created_at' => Carbon::now(),
|
|
'updated_at' => Carbon::now(),
|
|
];
|
|
}
|
|
|
|
public function forEnsemble(NominationEnsemble $ensemble): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($ensemble) {
|
|
return [
|
|
'nomination_ensemble_id' => $ensemble->id,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function forStudent(Student $student): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($student) {
|
|
return [
|
|
'student_id' => $student->id,
|
|
];
|
|
});
|
|
}
|
|
}
|