diff --git a/app/Http/Controllers/Admin/TagController.php b/app/Http/Controllers/Admin/TagController.php index e70185cdd0e48262cf3c087c36e80e82fc83be6a..3c67b28a3c565d8b65fab8bf13957fc983f1a464 100644 --- a/app/Http/Controllers/Admin/TagController.php +++ b/app/Http/Controllers/Admin/TagController.php @@ -41,7 +41,7 @@ public function create() */ public function store(Store $request) { - $tag = Tag::create($request->only('name')); + $tag = Tag::create($request->only('name', 'keywords', 'description')); if ($request->ajax()) { return response()->json($tag); diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index 9307fdd83862f89951e4ba80a0ab810fc5c13d6b..5ecad214700907cc8b1059c6785c65eb04c7c4c6 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -153,13 +153,14 @@ public function category($id) * 获取标签下的文章 * * @param $id + * @update 2019年10月15日 11:27:03 by jason * * @return \Illuminate\Contracts\View\Factory */ public function tag($id) { - // 获取标签 - $tag = Tag::select('id', 'name')->where('id', $id)->first(); + // 获取标签 以及关键字 + $tag = Tag::select('id', 'name', 'keywords', 'description')->where('id', $id)->first(); if ($tag === null) { return abort(404); } @@ -171,8 +172,8 @@ public function tag($id) ->paginate(10); $head = [ 'title' => $tag->name, - 'keywords' => '', - 'description' => '', + 'keywords' => $tag -> keywords ?? '', + 'description' => $tag -> description ?? '', ]; $assign = [ 'category_id' => 'index', diff --git a/app/Models/Tag.php b/app/Models/Tag.php index faf533cc9d9c748ff561be2edfbe874defe556d8..93008755768af1c02b88d56d663bae1717268b4a 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -11,6 +11,8 @@ * @property int $id 标签主键 * @property string $name 标签名 * @property string $slug slug + * @property string $keywords 标签关键词 + * @property string $description 标签描述主要是 SEO * * @author hanmeimei */ diff --git a/database/migrations/2017_07_11_225347_create_tags_table.php b/database/migrations/2017_07_11_225347_create_tags_table.php index ec6340d7dc7c3d1aff89936d8e57b096d3271a4a..ae4f02cdbb43b630b5b266585a7945bd41deb185 100644 --- a/database/migrations/2017_07_11_225347_create_tags_table.php +++ b/database/migrations/2017_07_11_225347_create_tags_table.php @@ -7,7 +7,8 @@ class CreateTagsTable extends Migration { /** * Run the migrations. - * + * @update 2019年10月15日 11:28:45 by jason + * @desc 添加 标签的关键字和描述。 * @return void */ public function up() @@ -16,6 +17,8 @@ public function up() $table->increments('id')->comment('标签主键'); $table->string('name', 20)->default('')->comment('标签名'); $table->string('slug')->default('')->comment('slug'); + $table->string('keywords')->default('')->comment('标签的关键字'); + $table->string('description')->default('')->comment('标签的描述'); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/seeds/TagsTableSeeder.php b/database/seeds/TagsTableSeeder.php index 69c90931b4ac191b934c85e0b2165114af3ea0b8..1e5b8edadfe27912cb8ccb16a9aca4d06ec021e8 100644 --- a/database/seeds/TagsTableSeeder.php +++ b/database/seeds/TagsTableSeeder.php @@ -14,28 +14,34 @@ public function run() DB::table('tags')->truncate(); DB::table('tags')->insert([ [ - 'id' => 1, - 'name' => 'laravel', - 'slug' => 'laravel', - 'created_at' => '2017-7-16 07:35:12', - 'updated_at' => '2016-7-16 07:35:12', - 'deleted_at' => null, + 'id' => 1, + 'name' => 'laravel', + 'slug' => 'laravel', + 'keywords' => 'laravel', + 'description' => 'Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。', + 'created_at' => '2017-7-16 07:35:12', + 'updated_at' => '2016-7-16 07:35:12', + 'deleted_at' => null, ], [ - 'id' => 2, - 'name' => 'test', - 'slug' => 'test', - 'created_at' => '2019-01-04 15:35:12', - 'updated_at' => '2019-01-04 15:35:12', - 'deleted_at' => null, + 'id' => 2, + 'name' => 'test', + 'slug' => 'test', + 'keywords' => 'test', + 'description' => '测试描述', + 'created_at' => '2019-01-04 15:35:12', + 'updated_at' => '2019-01-04 15:35:12', + 'deleted_at' => null, ], [ - 'id' => 3, - 'name' => '已删除', - 'slug' => 'deleted', - 'created_at' => '2019-01-04 15:35:12', - 'updated_at' => '2019-01-04 15:35:12', - 'deleted_at' => '2019-01-04 15:35:12', + 'id' => 3, + 'name' => '已删除', + 'slug' => 'deleted', + 'keywords' => 'delete', + 'description' => '删除的标签', + 'created_at' => '2019-01-04 15:35:12', + 'updated_at' => '2019-01-04 15:35:12', + 'deleted_at' => '2019-01-04 15:35:12', ], ]); } diff --git a/resources/views/admin/tag/create.blade.php b/resources/views/admin/tag/create.blade.php index 64fbfd2f51332dc6fc53ed541bcc2c0a23cf705b..6b68abf0a09bace5171e77674fb5b9980ca91f06 100644 --- a/resources/views/admin/tag/create.blade.php +++ b/resources/views/admin/tag/create.blade.php @@ -23,6 +23,18 @@ + + {{ __('Keywords') }} + + + + + + {{ __('Description') }} + + + + diff --git a/resources/views/admin/tag/edit.blade.php b/resources/views/admin/tag/edit.blade.php index fc6b2dd785e1515e1119ef1bf331baeb99fa70b6..c084bacc9f53c04bdb40ffc7a3937baee427aa18 100644 --- a/resources/views/admin/tag/edit.blade.php +++ b/resources/views/admin/tag/edit.blade.php @@ -23,6 +23,18 @@ + + {{ __('Keywords') }} + + + + + + {{ __('Description') }} + + + + diff --git a/resources/views/admin/tag/index.blade.php b/resources/views/admin/tag/index.blade.php index 2dc4e399a81fbae0612cc930907e8dac965ce72b..60c106092781a3c748e34e87a570b7e43fb0bdc1 100644 --- a/resources/views/admin/tag/index.blade.php +++ b/resources/views/admin/tag/index.blade.php @@ -35,7 +35,9 @@ @endif - {{ __('Edit') }} | + @if(is_null($v->deleted_at)) + {{ __('Edit') }} | + @endif @if(is_null($v->deleted_at)) {{ __('Delete') }} @else