jonnybarnes.uk/database/factories/NoteFactory.php

42 lines
835 B
PHP
Raw Normal View History

<?php
2020-10-17 17:15:06 +01:00
namespace Database\Factories;
use App\Models\Note;
use Exception;
2020-10-17 17:15:06 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
2023-02-18 09:34:57 +00:00
/**
* @psalm-suppress UnusedClass
*
2023-02-18 09:34:57 +00:00
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Note>
*/
2020-10-17 17:15:06 +01:00
class NoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Note::class;
/**
* Define the model's default state.
*
2023-02-18 09:34:57 +00:00
* @return array<string, mixed>
2022-07-09 10:08:26 +01:00
*
* @throws Exception
2020-10-17 17:15:06 +01:00
*/
2023-02-18 09:34:57 +00:00
public function definition(): array
2020-10-17 17:15:06 +01:00
{
$now = Carbon::now()->subDays(random_int(5, 15));
2020-10-17 17:15:06 +01:00
return [
'note' => $this->faker->paragraph,
'created_at' => $now,
'updated_at' => $now,
];
}
}