36 lines
976 B
PHP
36 lines
976 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
|
|
*/
|
|
class CategoryFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->unique()->randomElement([
|
|
'生活随笔', '旅行日记', '美食探店', '穿搭分享',
|
|
'居家装饰', '读书笔记', '摄影作品', '数码科技',
|
|
'健身运动', '心情日志', '工作感悟', '艺术欣赏'
|
|
]);
|
|
|
|
return [
|
|
'name' => $name,
|
|
'slug' => Str::slug($name) . '-' . fake()->unique()->randomNumber(4),
|
|
'description' => fake()->sentence(10),
|
|
'sort_order' => fake()->numberBetween(0, 10),
|
|
'is_active' => true,
|
|
];
|
|
}
|
|
}
|
|
|