*/ class InvoiceFactory extends Factory { protected $model = Invoice::class; /** * Define the model's default state. * * @return array */ public function definition() { return [ 'greeting' => $this->faker->words(4, true), 'to' => ReceiverRequestFactory::new()->create(), 'status' => InvoiceStatus::NEW->value, 'via' => BillKind::POST->value ]; } public function to(ReceiverRequestFactory $to): self { return $this->state(['to' => $to->create()]); } public function sentAt(Carbon $sentAt): self { return $this->state(['sent_at' => $sentAt]); } public function status(InvoiceStatus $status): self { return $this->state(['status' => $status->value]); } public function via(BillKind $via): self { return $this->state(['via' => $via->value]); } }