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

72 lines
1.9 KiB
PHTML

6 months ago
<?php
namespace Database\Factories;
use App\Models\Group;
use App\Models\User;
6 months ago
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
*/
class PostFactory extends Factory
{
4 months ago
public $icons = [
'ri-home-4-line',
'ri-building-line',
'ri-mail-open-line',
'ri-award-line',
'ri-line-chart-line',
'ri-verified-badge-line',
'ri-pie-chart-2-line',
'ri-printer-line',
'ri-service-line',
'ri-chat-1-line',
'ri-compasses-2-line',
'ri-code-s-slash-line',
'ri-phone-line',
'ri-rss-line',
'ri-fingerprint-line',
'ri-trophy-line',
'ri-shopping-cart-line',
'ri-hand-heart-line',
'ri-funds-line',
'ri-heart-2-line',
'ri-map-pin-line',
'ri-notification-2-line',
'ri-alarm-line',
'ri-user-6-line',
'ri-cloudy-2-line',
'ri-key-2-line',
'ri-customer-service-2-line',
'ri-bar-chart-grouped-line',
'ri-survey-line',
'ri-image-circle-line',
'ri-mic-2-line',
'ri-speed-up-line',
];
6 months ago
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = $this->faker->unique()->realText(75);
6 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),
4 months ago
'user_id' => User::where('id','<',6)->inRandomOrder()->first()->id,
'icon' => $this->icons[rand(0,count($this->icons)-1)],
6 months ago
];
}
}