43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\{Article, ArticleCategory};
|
|
|
|
class ArticleSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
Article::truncate();
|
|
ArticleCategory::truncate();
|
|
$categoris = [
|
|
['name' => '帮助', 'is_show' => 1],
|
|
['name' => '协议', 'is_show' => 1],
|
|
['name' => '文章', 'is_show' => 1, 'children' => [
|
|
['name' => '自然', 'is_show' => 1],
|
|
['name' => '文化', 'is_show' => 1],
|
|
['name' => '生活', 'is_show' => 1],
|
|
]],
|
|
];
|
|
foreach($categoris as $item) {
|
|
$category = ArticleCategory::create($item);
|
|
}
|
|
|
|
$articles = [
|
|
['category_id' => 2, 'title' => '关于我们', 'author_name' => 'Administrator', 'jump_type' => 0, 'is_show' => 1],
|
|
['category_id' => 2, 'title' => '服务协议', 'author_name' => 'Administrator', 'jump_type' => 0, 'is_show' => 1],
|
|
['category_id' => 2, 'title' => '隐私协议', 'author_name' => 'Administrator', 'jump_type' => 0, 'is_show' => 1],
|
|
['category_id' => 2, 'title' => '佣金说明', 'author_name' => 'Administrator', 'jump_type' => 0, 'is_show' => 1],
|
|
];
|
|
foreach($articles as $item) {
|
|
$article = Article::create($item);
|
|
}
|
|
}
|
|
}
|