InitTemplateData.php
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
namespace App\Console\Commands;
use App\Models\OnePoem;
use App\Models\PackPoem;
use App\Models\VideoTemp;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class InitTemplateData extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'init:temp';
/**
* The console command description.
*
* @var string
*/
protected $description = '初始化模板数据';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// 一言表
OnePoem::query()->truncate();
$one_poem = new OnePoem();
$one_poem->id = 1;
$one_poem->title = '诉衷情2';
$one_poem->author = '欧阳修';
$one_poem->content = '清晨帘幕卷轻霜。';
$one_poem->annotate = '诉衷情 --清晨帘幕卷轻霜。';
$one_poem->spelling = 'qing chen lian mu juan qing shuang';
$one_poem->en = 'morning ...';
$one_poem->state = 0;
$one_poem->created_at = Carbon::now();
$one_poem->updated_at = Carbon::now();
$one_poem->save();
// 众妙表
PackPoem::query()->truncate();
$pack_poem = new PackPoem();
$pack_poem->id = 1;
$pack_poem->title = '辛丑年 庚子月 已酉时 巳时';
$pack_poem->subtitle = '2022年01月12日13点22分';
$pack_poem->left_text = '欧阳修';
$pack_poem->right_text = '冬';
$pack_poem->poem_id = 1;
$pack_poem->state = 0;
$pack_poem->created_at = Carbon::now();
$pack_poem->updated_at = Carbon::now();
$pack_poem->save();
// 模板表
VideoTemp::query()->truncate();
$video_temp = new VideoTemp();
$video_temp->title = 'test';
$video_temp->bgm_url = 'files/ce1f0f0a995f93ff2e6d68451ab0873e.png';
$video_temp->bg_music = 0;
$video_temp->state = 0;
$video_temp->save();
// 菜单初始化
\Dcat\Admin\Models\Menu::query()->truncate();
$admin_menu = json_decode(Storage::disk('public')->get('PoemData/admin_menu.json'), true);
$data = $admin_menu['RECORDS'];
foreach ($data as $item){
$item['created_at'] = Carbon::now();
$item['updated_at'] = Carbon::now();
\Dcat\Admin\Models\Menu::query()->create($item);
}
return 0;
}
}