李帅

init

<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\PickPoetryVerse;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class PickPoetryVerseController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new PickPoetryVerse(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('pick_id');
$grid->column('verse_id');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new PickPoetryVerse(), function (Show $show) {
$show->field('id');
$show->field('pick_id');
$show->field('verse_id');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new PickPoetryVerse(), function (Form $form) {
$form->display('id');
$form->text('pick_id');
$form->text('verse_id');
$form->display('created_at');
$form->display('updated_at');
});
}
}
This diff is collapsed. Click to expand it.
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class PickPoetryVerse extends Model
{
use HasDateTimeFormatter;
protected $table = 'pick_poetry_verse';
}
......@@ -15,7 +15,7 @@ class CreatePoetryTable extends Migration
{
Schema::create('poetry', function (Blueprint $table) {
$table->increments('id');
$table->foreignId('author_id')->constrained('author','id');
$table->unsignedBigInteger('author_id')->index()->comment('作者id');
$table->string('name')->default('')->comment('题目');
$table->string('subname')->default('')->comment('小标题');
$table->string('alias')->default('')->comment('别名');
......
......@@ -15,7 +15,7 @@ class CreateVerseTable extends Migration
{
Schema::create('verse', function (Blueprint $table) {
$table->increments('id');
$table->foreignId('poetry_id')->constrained('poetry','id');
$table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
$table->string('stanza')->default('')->comment('诗节');
$table->text('annotate')->comment('注解');
$table->string('spelling')->default('')->comment('拼音');
......
......@@ -15,8 +15,8 @@ class CreatePoetryTagTable extends Migration
{
Schema::create('poetry_tag', function (Blueprint $table) {
$table->increments('id');
$table->foreignId('poetry_id')->constrained('poetry','id');
$table->foreignId('tag_id')->constrained('tags','id');
$table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
$table->unsignedBigInteger('tag_id')->index()->comment('标签id');
});
}
......
......@@ -17,9 +17,9 @@ class CreatePickPoetryTable extends Migration
$table->increments('id');
$table->string('title')->default('')->comment('标题');
$table->string('subtitle')->default('')->comment('副标题');
$table->string('left_tag_id')->default('')->comment('左侧文本');
$table->string('right_tag_id')->default('')->comment('右侧文本');
$table->foreignId('poetry_id')->constrained('poetry','id');
$table->string('left_text')->default('')->comment('左侧文本');
$table->string('right_text')->default('')->comment('右侧文本');
$table->unsignedBigInteger('poetry_id')->index()->comment('诗词id');
$table->unsignedBigInteger('use_num')->comment('使用次数');
$table->unsignedTinyInteger('state')->comment('状态');
$table->timestamps();
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePickPoetryVerseTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('pick_poetry_verse', function (Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('pick_id')->index()->comment('官方秀id');
$table->unsignedBigInteger('verse_id')->index()->comment('诗句(节)id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pick_poetry_verse');
}
}
......@@ -18,8 +18,7 @@ class CreateUserShowTable extends Migration
$table->unsignedBigInteger('user_id')->comment('用户id');
$table->text('content')->comment('内容描述');
$table->unsignedTinyInteger('type')->comment('1=图文,2=视频');
// $table->unsignedBigInteger('pick_id')->comment('引用的官方秀id');
$table->foreignId('poetry_id')->constrained('pick_poetry','id');
$table->unsignedBigInteger('pick_id')->index()->comment('引用的秀id');
$table->integer('fav_num')->comment('收藏数');
$table->integer('view_num')->comment('观看数');
$table->integer('praise_num')->comment('点赞数');
......
......@@ -48,6 +48,8 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection tokenable_id
* @property Grid\Column|Collection abilities
* @property Grid\Column|Collection last_used_at
* @property Grid\Column|Collection poetry_id
* @property Grid\Column|Collection tag_id
* @property Grid\Column|Collection email_verified_at
*
* @method Grid\Column|Collection id(string $label = null)
......@@ -87,6 +89,8 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection tokenable_id(string $label = null)
* @method Grid\Column|Collection abilities(string $label = null)
* @method Grid\Column|Collection last_used_at(string $label = null)
* @method Grid\Column|Collection poetry_id(string $label = null)
* @method Grid\Column|Collection tag_id(string $label = null)
* @method Grid\Column|Collection email_verified_at(string $label = null)
*/
class Grid {}
......@@ -131,6 +135,8 @@ namespace Dcat\Admin {
* @property Show\Field|Collection tokenable_id
* @property Show\Field|Collection abilities
* @property Show\Field|Collection last_used_at
* @property Show\Field|Collection poetry_id
* @property Show\Field|Collection tag_id
* @property Show\Field|Collection email_verified_at
*
* @method Show\Field|Collection id(string $label = null)
......@@ -170,6 +176,8 @@ namespace Dcat\Admin {
* @method Show\Field|Collection tokenable_id(string $label = null)
* @method Show\Field|Collection abilities(string $label = null)
* @method Show\Field|Collection last_used_at(string $label = null)
* @method Show\Field|Collection poetry_id(string $label = null)
* @method Show\Field|Collection tag_id(string $label = null)
* @method Show\Field|Collection email_verified_at(string $label = null)
*/
class Show {}
......