44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\DoublerRequest;
|
|
use App\Models\Event;
|
|
use App\Models\Student;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class DoublerRequestFactory extends Factory
|
|
{
|
|
protected $model = DoublerRequest::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'request' => $this->faker->word(),
|
|
'created_at' => Carbon::now(),
|
|
'updated_at' => Carbon::now(),
|
|
'event_id' => Event::factory(),
|
|
'student_id' => Student::factory(),
|
|
];
|
|
}
|
|
|
|
public function forStudent(Student $student): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($student) {
|
|
return [
|
|
'student_id' => $student->id,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function forEvent(Event $event): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($event) {
|
|
return [
|
|
'event_id' => $event->id,
|
|
];
|
|
});
|
|
}
|
|
}
|