李帅

init

1 +<?php
2 +
3 +namespace App\Admin\Controllers;
4 +
5 +use App\Admin\Repositories\PickPoetryVerse;
6 +use Dcat\Admin\Form;
7 +use Dcat\Admin\Grid;
8 +use Dcat\Admin\Show;
9 +use Dcat\Admin\Http\Controllers\AdminController;
10 +
11 +class PickPoetryVerseController extends AdminController
12 +{
13 + /**
14 + * Make a grid builder.
15 + *
16 + * @return Grid
17 + */
18 + protected function grid()
19 + {
20 + return Grid::make(new PickPoetryVerse(), function (Grid $grid) {
21 + $grid->column('id')->sortable();
22 + $grid->column('pick_id');
23 + $grid->column('verse_id');
24 + $grid->column('created_at');
25 + $grid->column('updated_at')->sortable();
26 +
27 + $grid->filter(function (Grid\Filter $filter) {
28 + $filter->equal('id');
29 +
30 + });
31 + });
32 + }
33 +
34 + /**
35 + * Make a show builder.
36 + *
37 + * @param mixed $id
38 + *
39 + * @return Show
40 + */
41 + protected function detail($id)
42 + {
43 + return Show::make($id, new PickPoetryVerse(), function (Show $show) {
44 + $show->field('id');
45 + $show->field('pick_id');
46 + $show->field('verse_id');
47 + $show->field('created_at');
48 + $show->field('updated_at');
49 + });
50 + }
51 +
52 + /**
53 + * Make a form builder.
54 + *
55 + * @return Form
56 + */
57 + protected function form()
58 + {
59 + return Form::make(new PickPoetryVerse(), function (Form $form) {
60 + $form->display('id');
61 + $form->text('pick_id');
62 + $form->text('verse_id');
63 +
64 + $form->display('created_at');
65 + $form->display('updated_at');
66 + });
67 + }
68 +}
This diff is collapsed. Click to expand it.
1 +<?php
2 +
3 +namespace App\Models;
4 +
5 +use Dcat\Admin\Traits\HasDateTimeFormatter;
6 +
7 +use Illuminate\Database\Eloquent\Model;
8 +
9 +class PickPoetryVerse extends Model
10 +{
11 + use HasDateTimeFormatter;
12 + protected $table = 'pick_poetry_verse';
13 +
14 +}
...@@ -15,7 +15,7 @@ class CreatePoetryTable extends Migration ...@@ -15,7 +15,7 @@ class CreatePoetryTable extends Migration
15 { 15 {
16 Schema::create('poetry', function (Blueprint $table) { 16 Schema::create('poetry', function (Blueprint $table) {
17 $table->increments('id'); 17 $table->increments('id');
18 - $table->foreignId('author_id')->constrained('author','id'); 18 + $table->unsignedBigInteger('author_id')->index()->comment('作者id');
19 $table->string('name')->default('')->comment('题目'); 19 $table->string('name')->default('')->comment('题目');
20 $table->string('subname')->default('')->comment('小标题'); 20 $table->string('subname')->default('')->comment('小标题');
21 $table->string('alias')->default('')->comment('别名'); 21 $table->string('alias')->default('')->comment('别名');
......
...@@ -15,7 +15,7 @@ class CreateVerseTable extends Migration ...@@ -15,7 +15,7 @@ class CreateVerseTable extends Migration
15 { 15 {
16 Schema::create('verse', function (Blueprint $table) { 16 Schema::create('verse', function (Blueprint $table) {
17 $table->increments('id'); 17 $table->increments('id');
18 - $table->foreignId('poetry_id')->constrained('poetry','id'); 18 + $table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
19 $table->string('stanza')->default('')->comment('诗节'); 19 $table->string('stanza')->default('')->comment('诗节');
20 $table->text('annotate')->comment('注解'); 20 $table->text('annotate')->comment('注解');
21 $table->string('spelling')->default('')->comment('拼音'); 21 $table->string('spelling')->default('')->comment('拼音');
......
...@@ -15,8 +15,8 @@ class CreatePoetryTagTable extends Migration ...@@ -15,8 +15,8 @@ class CreatePoetryTagTable extends Migration
15 { 15 {
16 Schema::create('poetry_tag', function (Blueprint $table) { 16 Schema::create('poetry_tag', function (Blueprint $table) {
17 $table->increments('id'); 17 $table->increments('id');
18 - $table->foreignId('poetry_id')->constrained('poetry','id'); 18 + $table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
19 - $table->foreignId('tag_id')->constrained('tags','id'); 19 + $table->unsignedBigInteger('tag_id')->index()->comment('标签id');
20 }); 20 });
21 } 21 }
22 22
......
...@@ -17,9 +17,9 @@ class CreatePickPoetryTable extends Migration ...@@ -17,9 +17,9 @@ class CreatePickPoetryTable extends Migration
17 $table->increments('id'); 17 $table->increments('id');
18 $table->string('title')->default('')->comment('标题'); 18 $table->string('title')->default('')->comment('标题');
19 $table->string('subtitle')->default('')->comment('副标题'); 19 $table->string('subtitle')->default('')->comment('副标题');
20 - $table->string('left_tag_id')->default('')->comment('左侧文本'); 20 + $table->string('left_text')->default('')->comment('左侧文本');
21 - $table->string('right_tag_id')->default('')->comment('右侧文本'); 21 + $table->string('right_text')->default('')->comment('右侧文本');
22 - $table->foreignId('poetry_id')->constrained('poetry','id'); 22 + $table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
23 $table->unsignedBigInteger('use_num')->comment('使用次数'); 23 $table->unsignedBigInteger('use_num')->comment('使用次数');
24 $table->unsignedTinyInteger('state')->comment('状态'); 24 $table->unsignedTinyInteger('state')->comment('状态');
25 $table->timestamps(); 25 $table->timestamps();
......
1 +<?php
2 +
3 +use Illuminate\Support\Facades\Schema;
4 +use Illuminate\Database\Schema\Blueprint;
5 +use Illuminate\Database\Migrations\Migration;
6 +
7 +class CreatePickPoetryVerseTable extends Migration
8 +{
9 + /**
10 + * Run the migrations.
11 + *
12 + * @return void
13 + */
14 + public function up()
15 + {
16 + Schema::create('pick_poetry_verse', function (Blueprint $table) {
17 + $table->increments('id');
18 + $table->unsignedBigInteger('pick_id')->index()->comment('官方秀id');
19 + $table->unsignedBigInteger('verse_id')->index()->comment('诗句(节)id');
20 + });
21 + }
22 +
23 + /**
24 + * Reverse the migrations.
25 + *
26 + * @return void
27 + */
28 + public function down()
29 + {
30 + Schema::dropIfExists('pick_poetry_verse');
31 + }
32 +}
...@@ -18,8 +18,7 @@ class CreateUserShowTable extends Migration ...@@ -18,8 +18,7 @@ class CreateUserShowTable extends Migration
18 $table->unsignedBigInteger('user_id')->comment('用户id'); 18 $table->unsignedBigInteger('user_id')->comment('用户id');
19 $table->text('content')->comment('内容描述'); 19 $table->text('content')->comment('内容描述');
20 $table->unsignedTinyInteger('type')->comment('1=图文,2=视频'); 20 $table->unsignedTinyInteger('type')->comment('1=图文,2=视频');
21 -// $table->unsignedBigInteger('pick_id')->comment('引用的官方秀id'); 21 + $table->unsignedBigInteger('pick_id')->index()->comment('引用的秀id');
22 - $table->foreignId('poetry_id')->constrained('pick_poetry','id');
23 $table->integer('fav_num')->comment('收藏数'); 22 $table->integer('fav_num')->comment('收藏数');
24 $table->integer('view_num')->comment('观看数'); 23 $table->integer('view_num')->comment('观看数');
25 $table->integer('praise_num')->comment('点赞数'); 24 $table->integer('praise_num')->comment('点赞数');
......
...@@ -48,6 +48,8 @@ namespace Dcat\Admin { ...@@ -48,6 +48,8 @@ namespace Dcat\Admin {
48 * @property Grid\Column|Collection tokenable_id 48 * @property Grid\Column|Collection tokenable_id
49 * @property Grid\Column|Collection abilities 49 * @property Grid\Column|Collection abilities
50 * @property Grid\Column|Collection last_used_at 50 * @property Grid\Column|Collection last_used_at
51 + * @property Grid\Column|Collection poetry_id
52 + * @property Grid\Column|Collection tag_id
51 * @property Grid\Column|Collection email_verified_at 53 * @property Grid\Column|Collection email_verified_at
52 * 54 *
53 * @method Grid\Column|Collection id(string $label = null) 55 * @method Grid\Column|Collection id(string $label = null)
...@@ -87,6 +89,8 @@ namespace Dcat\Admin { ...@@ -87,6 +89,8 @@ namespace Dcat\Admin {
87 * @method Grid\Column|Collection tokenable_id(string $label = null) 89 * @method Grid\Column|Collection tokenable_id(string $label = null)
88 * @method Grid\Column|Collection abilities(string $label = null) 90 * @method Grid\Column|Collection abilities(string $label = null)
89 * @method Grid\Column|Collection last_used_at(string $label = null) 91 * @method Grid\Column|Collection last_used_at(string $label = null)
92 + * @method Grid\Column|Collection poetry_id(string $label = null)
93 + * @method Grid\Column|Collection tag_id(string $label = null)
90 * @method Grid\Column|Collection email_verified_at(string $label = null) 94 * @method Grid\Column|Collection email_verified_at(string $label = null)
91 */ 95 */
92 class Grid {} 96 class Grid {}
...@@ -131,6 +135,8 @@ namespace Dcat\Admin { ...@@ -131,6 +135,8 @@ namespace Dcat\Admin {
131 * @property Show\Field|Collection tokenable_id 135 * @property Show\Field|Collection tokenable_id
132 * @property Show\Field|Collection abilities 136 * @property Show\Field|Collection abilities
133 * @property Show\Field|Collection last_used_at 137 * @property Show\Field|Collection last_used_at
138 + * @property Show\Field|Collection poetry_id
139 + * @property Show\Field|Collection tag_id
134 * @property Show\Field|Collection email_verified_at 140 * @property Show\Field|Collection email_verified_at
135 * 141 *
136 * @method Show\Field|Collection id(string $label = null) 142 * @method Show\Field|Collection id(string $label = null)
...@@ -170,6 +176,8 @@ namespace Dcat\Admin { ...@@ -170,6 +176,8 @@ namespace Dcat\Admin {
170 * @method Show\Field|Collection tokenable_id(string $label = null) 176 * @method Show\Field|Collection tokenable_id(string $label = null)
171 * @method Show\Field|Collection abilities(string $label = null) 177 * @method Show\Field|Collection abilities(string $label = null)
172 * @method Show\Field|Collection last_used_at(string $label = null) 178 * @method Show\Field|Collection last_used_at(string $label = null)
179 + * @method Show\Field|Collection poetry_id(string $label = null)
180 + * @method Show\Field|Collection tag_id(string $label = null)
173 * @method Show\Field|Collection email_verified_at(string $label = null) 181 * @method Show\Field|Collection email_verified_at(string $label = null)
174 */ 182 */
175 class Show {} 183 class Show {}
......