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/PostFactory.php

36 lines
950 B
PHTML

8 months ago
<?php
namespace Database\Factories;
use App\Models\Group;
use App\Models\User;
8 months ago
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
*/
class PostFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = $this->faker->unique()->realText(75);
8 months ago
return [
//
'title' => $title,
'slug' => sluger($title),
'subtitle' => $this->faker->realText(),
'body' => $this->faker->realText(500),
'group_id' => Group::inRandomOrder()->first()->id,
'hash' => str_pad(dechex(crc32($title)), 8, '0', STR_PAD_LEFT),
'status' => rand(0,1),
'view' => rand(0,999),
'user_id' => User::inRandomOrder()->first()->id,
8 months ago
];
}
}