adrema/database/factories/Invoice/Models/InvoiceFactory.php

56 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-12-16 01:13:49 +01:00
<?php
namespace Database\Factories\Invoice\Models;
2023-12-16 11:18:00 +01:00
use App\Invoice\BillKind;
2023-12-16 01:13:49 +01:00
use App\Invoice\Enums\InvoiceStatus;
use App\Invoice\Models\Invoice;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\Feature\Invoice\ReceiverRequestFactory;
/**
* @extends Factory<Invoice>
*/
class InvoiceFactory extends Factory
{
protected $model = Invoice::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'greeting' => $this->faker->words(4, true),
2023-12-16 13:08:17 +01:00
'to' => ReceiverRequestFactory::new()->create(),
'status' => InvoiceStatus::NEW->value,
2023-12-17 22:33:29 +01:00
'via' => BillKind::POST->value,
'usage' => $this->faker->words(4, true),
2023-12-18 02:17:31 +01:00
'mail_email' => $this->faker->safeEmail(),
2023-12-16 01:13:49 +01:00
];
}
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]);
}
2023-12-16 11:18:00 +01:00
public function via(BillKind $via): self
{
return $this->state(['via' => $via->value]);
}
2023-12-16 01:13:49 +01:00
}