Skip to content

Instantly share code, notes, and snippets.

@filipfilipovich
Created May 26, 2023 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipfilipovich/57bb4122fd062c3b53fad077fe3e1410 to your computer and use it in GitHub Desktop.
Save filipfilipovich/57bb4122fd062c3b53fad077fe3e1410 to your computer and use it in GitHub Desktop.
BookFactory class
<?php
namespace Database\Factories;
use App\Models\Book;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Book>
*/
class BookFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'title' => ucwords($this->faker->words($this->faker->numberBetween(1, 5), true)),
'author' => $this->faker->name(),
'isbn' => $this->faker->isbn13(),
'number_sold' => $this->faker->numberBetween(100, 1000000),
'date_published' => $this->faker->dateTime(),
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment