generated from liutk/owl-admin-base
38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use App\Models\Train\Book;
|
|
use App\Models\Keyword;
|
|
use App\Enums\BookType;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
|
|
*/
|
|
class BookFactory extends Factory
|
|
{
|
|
protected $model = Book::class;
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'title' => $this->faker->sentence,
|
|
'category_id' => Keyword::where('parent_key', 'book_category')->inRandomOrder()->value('key'),
|
|
'cover_image' => 'https://via.placeholder.com/100x100.png',
|
|
'description' => $this->faker->paragraph,
|
|
'type' => $this->faker->randomElement(BookType::class),
|
|
'content' => '<h1>富文本 H1<h1><img src="https://via.placeholder.com/100x100.png" width="100%" height="100%" />',
|
|
'video' => 'https://qiniu.abcdefg.fun/mp4-1.mp4',
|
|
'files' => [
|
|
['id' => '1', 'name' => '1.png', 'url' => 'https://qiniu.abcdefg.fun/avatar/avatar.png', 'value' => 'https://qiniu.abcdefg.fun/avatar/avatar.png', "state" => "uploaded"],
|
|
['id' => '2','name' => '2.png', 'url' => 'https://qiniu.abcdefg.fun/avatar/avatar2.png', 'value' => 'https://qiniu.abcdefg.fun/avatar/avatar.png', "state" => "uploaded"],
|
|
],
|
|
];
|
|
}
|
|
}
|