You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xshop/database/factories/ProductFactory.php

32 lines
782 B
PHP

<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Product>
*/
class ProductFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$rand = rand(1,2);
$title = ($rand == 1?'mobile':'Tablet').' ' . $this->faker->unique()->firstNameFemale;
return [
//
'name' => $title,
'slug' => sluger($title),
'excerpt' => $this->faker->realText(150),
'user_id' => 1,
'category_id' => $rand,
'description' => $this->faker->realText(600),
];
}
}