| 123456789101112131415161718192021222324252627282930 |
- <?php
- namespace Database\Factories;
- use App\Models\Contract;
- use Illuminate\Database\Eloquent\Factories\Factory;
- /**
- * @extends Factory<Contract>
- */
- class ContractFactory extends Factory
- {
- protected $model = Contract::class;
- public function definition(): array
- {
- return [
- 'year' => (int) date('Y'),
- 'contract_number' => fake()->unique()->bothify('CONTRACT-####-??'),
- 'contract_date' => fake()->dateTimeBetween('-1 year', 'now')->format('Y-m-d'),
- ];
- }
- public function forYear(int $year): static
- {
- return $this->state(fn (array $attributes) => [
- 'year' => $year,
- ]);
- }
- }
|