From 076df42a0c7dd094e752a815f3b4d68e69087799 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Sun, 28 Aug 2016 18:54:45 +0800 Subject: [PATCH 01/13] get up to date --- README.md | 1 - readme.md | 27 --------------------------- 2 files changed, 28 deletions(-) delete mode 100644 README.md delete mode 100644 readme.md diff --git a/README.md b/README.md deleted file mode 100644 index 9dfcc1d..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# NoticeBoard \ No newline at end of file diff --git a/readme.md b/readme.md deleted file mode 100644 index 7f8816d..0000000 --- a/readme.md +++ /dev/null @@ -1,27 +0,0 @@ -# Laravel PHP Framework - -[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) -[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) -[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) - -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching. - -Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. - -## Official Documentation - -Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs). - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. - -## License - -The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). From 6c5230f733bf545cab5d825d4e1ebc243c1670e1 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Sun, 28 Aug 2016 18:56:03 +0800 Subject: [PATCH 02/13] Revert "Revert "created tables for apps"" This reverts commit 74c6af1bbd1688fff144df21057a49186c4031ca. --- .../2016_06_20_215205_create_users_table.php | 11 +++++ .../2016_08_27_225214_create_post_table.php | 40 +++++++++++++++++ .../2016_08_27_230247_create_reply_table.php | 41 ++++++++++++++++++ .../2016_08_27_230930_create_club_table.php | 43 +++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 database/migrations/2016_08_27_225214_create_post_table.php create mode 100644 database/migrations/2016_08_27_230247_create_reply_table.php create mode 100644 database/migrations/2016_08_27_230930_create_club_table.php diff --git a/database/migrations/2016_06_20_215205_create_users_table.php b/database/migrations/2016_06_20_215205_create_users_table.php index 718ddce..bd57c66 100644 --- a/database/migrations/2016_06_20_215205_create_users_table.php +++ b/database/migrations/2016_06_20_215205_create_users_table.php @@ -18,9 +18,20 @@ public function up() $table->string('email')->unique(); $table->string('password'); $table->string('class')->nullable(); + $table->string('grade'); $table->string('avatar')->nullable(); $table->string('powerschool_id')->nullable()->unique(); $table->string('type'); + $table->string('created_counts'); //累计发言数 + $table->string('identity'); // 用|分割不同身份,比如 1|2|3 + //个人信息 + $table->string('nickname'); + $table->string('condition'); + $table->text('self_intro'); + $table->string('wechat_ID'); + $table->string('QQ'); + $table->string('alternative_email'); + $table->string('phone'); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php new file mode 100644 index 0000000..1fe6105 --- /dev/null +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -0,0 +1,40 @@ +increments('id'); + $table->string('author_id')->nullable(); + $table->string('type'); + $table->string('club_post_type'); // 1 是默认 + $table->longText('content'); + $table->date('created_at'); + $table->date('last_edited_at'); + $table->string('edited_counts'); + $this->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::drop('posts'); + } +} diff --git a/database/migrations/2016_08_27_230247_create_reply_table.php b/database/migrations/2016_08_27_230247_create_reply_table.php new file mode 100644 index 0000000..c629401 --- /dev/null +++ b/database/migrations/2016_08_27_230247_create_reply_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->string('belongs_to')->nullable(); + $table->string('type'); + $table->longText('content'); + $table->date('created_at'); + $table->date('last_edited_at'); + $table->string('type'); + $table->string('edited_counts'); + $this->text('tags'); + $this->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::drop('replys'); + } +} diff --git a/database/migrations/2016_08_27_230930_create_club_table.php b/database/migrations/2016_08_27_230930_create_club_table.php new file mode 100644 index 0000000..7683f68 --- /dev/null +++ b/database/migrations/2016_08_27_230930_create_club_table.php @@ -0,0 +1,43 @@ +increments('id'); + $table->string('name'); + $table->string('avatar')->nullable(); + $table->string('powerschool_id')->nullable()->unique(); + $table->string('type'); + //社团信息 + $table->text('intro'); + $table->string('is_in_charge'); // 社长ID 多个用 | 分割 + $table->string('is_take_charge'); //负责人ID 多个用 | 分割 + $table->string('is_hidden'); //只对指定人员开放 + $table->string('created_at'); + + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::drop('clubs'); + } +} From d231eeb1b13baffd75f207a4c2865a99aa575689 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Sat, 24 Sep 2016 23:16:42 +0800 Subject: [PATCH 03/13] modify the database structure --- ...12_100000_create_password_resets_table.php | 2 +- .../2016_06_20_215205_create_users_table.php | 20 +++++------ .../2016_08_27_225214_create_post_table.php | 5 +-- .../2016_08_27_230247_create_reply_table.php | 2 +- .../2016_08_27_230930_create_club_table.php | 2 +- .../2016_09_24_224534_create_class_table.php | 34 ++++++++++++++++++ .../2016_09_24_224912_create_tags_table.php | 34 ++++++++++++++++++ ...30833_create_associate_club_user_table.php | 35 +++++++++++++++++++ 8 files changed, 119 insertions(+), 15 deletions(-) create mode 100644 database/migrations/2016_09_24_224534_create_class_table.php create mode 100644 database/migrations/2016_09_24_224912_create_tags_table.php create mode 100644 database/migrations/2016_09_24_230833_create_associate_club_user_table.php diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 00057f9..5ab6de7 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -26,6 +26,6 @@ public function up() */ public function down() { - Schema::drop('password_resets'); + Schema::dropIfExists('password_resets'); } } diff --git a/database/migrations/2016_06_20_215205_create_users_table.php b/database/migrations/2016_06_20_215205_create_users_table.php index bd57c66..a1cb210 100644 --- a/database/migrations/2016_06_20_215205_create_users_table.php +++ b/database/migrations/2016_06_20_215205_create_users_table.php @@ -21,17 +21,17 @@ public function up() $table->string('grade'); $table->string('avatar')->nullable(); $table->string('powerschool_id')->nullable()->unique(); - $table->string('type'); - $table->string('created_counts'); //累计发言数 - $table->string('identity'); // 用|分割不同身份,比如 1|2|3 + $table->string('type'); // 数字为用户身份: 1 public, 2 admin + $table->string('created_counts')->default(0); //累计发言数 + $table->string('identity'); // 用|分割不同权限,对应到assoc表单中的id //个人信息 - $table->string('nickname'); + $table->string('nickname')->nullable()->unique(); $table->string('condition'); - $table->text('self_intro'); - $table->string('wechat_ID'); - $table->string('QQ'); - $table->string('alternative_email'); - $table->string('phone'); + $table->text('self_intro')->nullable()->default("一言不发才是最吼的!"); + $table->string('wechat_ID')->unique(); + $table->string('QQ')->nullable()->unique(); + $table->string('alternative_email')->nullable(); + $table->string('phone')->nullable()->unique(); $table->rememberToken(); $table->timestamps(); }); @@ -44,6 +44,6 @@ public function up() */ public function down() { - Schema::drop('users'); + Schema::dropIfExists('users'); } } diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php index 1fe6105..e90b423 100644 --- a/database/migrations/2016_08_27_225214_create_post_table.php +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -16,8 +16,9 @@ public function up() $table->increments('id'); $table->string('author_id')->nullable(); $table->string('type'); - $table->string('club_post_type'); // 1 是默认 + $table->string('club_post_type')->default(1); // 1 是默认 $table->longText('content'); + $table->string('tags'); //格式 1|2|3|5, 数字为Tags id $table->date('created_at'); $table->date('last_edited_at'); $table->string('edited_counts'); @@ -35,6 +36,6 @@ public function up() public function down() { // - Schema::drop('posts'); + Schema::dropIfExists('posts'); } } diff --git a/database/migrations/2016_08_27_230247_create_reply_table.php b/database/migrations/2016_08_27_230247_create_reply_table.php index c629401..66a65cb 100644 --- a/database/migrations/2016_08_27_230247_create_reply_table.php +++ b/database/migrations/2016_08_27_230247_create_reply_table.php @@ -36,6 +36,6 @@ public function up() public function down() { // - Schema::drop('replys'); + Schema::dropIfExists('replys'); } } diff --git a/database/migrations/2016_08_27_230930_create_club_table.php b/database/migrations/2016_08_27_230930_create_club_table.php index 7683f68..14a69f7 100644 --- a/database/migrations/2016_08_27_230930_create_club_table.php +++ b/database/migrations/2016_08_27_230930_create_club_table.php @@ -38,6 +38,6 @@ public function up() public function down() { // - Schema::drop('clubs'); + Schema::dropIfExists('clubs'); } } diff --git a/database/migrations/2016_09_24_224534_create_class_table.php b/database/migrations/2016_09_24_224534_create_class_table.php new file mode 100644 index 0000000..907c154 --- /dev/null +++ b/database/migrations/2016_09_24_224534_create_class_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('classname')->unique(); + $table->test('class_intro'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::dropIfExists('class'); + } +} diff --git a/database/migrations/2016_09_24_224912_create_tags_table.php b/database/migrations/2016_09_24_224912_create_tags_table.php new file mode 100644 index 0000000..1ee7422 --- /dev/null +++ b/database/migrations/2016_09_24_224912_create_tags_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('tag')->unique(); + $table->test('tag_intro'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::dropIfExists('tags'); + } +} diff --git a/database/migrations/2016_09_24_230833_create_associate_club_user_table.php b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php new file mode 100644 index 0000000..ba04065 --- /dev/null +++ b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('club'); + $table->string('user'); + $table->string('level')->default(1); // 1:成员 2:负责人 3:社长 + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::dropIfExists('asscociate_club_user'); + } +} From 7bfb2c60c1c3e36475e989acf1d09df29d20c0c1 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Sun, 25 Sep 2016 22:54:08 +0800 Subject: [PATCH 04/13] fix database table --- .../2016_06_20_215205_create_users_table.php | 4 ++-- .../2016_08_27_225214_create_post_table.php | 5 ++--- .../2016_08_27_230247_create_reply_table.php | 8 +++----- .../2016_08_27_230930_create_club_table.php | 11 ++++------- .../2016_09_24_224534_create_class_table.php | 2 +- ...ble.php => 2016_09_24_224912_create_tag_table.php} | 6 +++--- 6 files changed, 15 insertions(+), 21 deletions(-) rename database/migrations/{2016_09_24_224912_create_tags_table.php => 2016_09_24_224912_create_tag_table.php} (78%) diff --git a/database/migrations/2016_06_20_215205_create_users_table.php b/database/migrations/2016_06_20_215205_create_users_table.php index a1cb210..2f3a848 100644 --- a/database/migrations/2016_06_20_215205_create_users_table.php +++ b/database/migrations/2016_06_20_215205_create_users_table.php @@ -12,7 +12,7 @@ class CreateUsersTable extends Migration */ public function up() { - Schema::create('users', function (Blueprint $table) { + Schema::create('user', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); @@ -27,7 +27,7 @@ public function up() //个人信息 $table->string('nickname')->nullable()->unique(); $table->string('condition'); - $table->text('self_intro')->nullable()->default("一言不发才是最吼的!"); + $table->text('self_intro')->nullable(); $table->string('wechat_ID')->unique(); $table->string('QQ')->nullable()->unique(); $table->string('alternative_email')->nullable(); diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php index e90b423..a7ce042 100644 --- a/database/migrations/2016_08_27_225214_create_post_table.php +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -12,17 +12,16 @@ class CreatePostTable extends Migration */ public function up() { - Schema::create('posts', function (Blueprint $table) { + Schema::create('post', function (Blueprint $table) { $table->increments('id'); $table->string('author_id')->nullable(); $table->string('type'); $table->string('club_post_type')->default(1); // 1 是默认 $table->longText('content'); $table->string('tags'); //格式 1|2|3|5, 数字为Tags id - $table->date('created_at'); $table->date('last_edited_at'); $table->string('edited_counts'); - $this->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 + $table->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_08_27_230247_create_reply_table.php b/database/migrations/2016_08_27_230247_create_reply_table.php index 66a65cb..3872488 100644 --- a/database/migrations/2016_08_27_230247_create_reply_table.php +++ b/database/migrations/2016_08_27_230247_create_reply_table.php @@ -12,17 +12,15 @@ class CreateReplyTable extends Migration */ public function up() { - Schema::create('replys', function (Blueprint $table) { + Schema::create('reply', function (Blueprint $table) { $table->increments('id'); $table->string('belongs_to')->nullable(); $table->string('type'); $table->longText('content'); - $table->date('created_at'); $table->date('last_edited_at'); - $table->string('type'); $table->string('edited_counts'); - $this->text('tags'); - $this->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 + $table->text('tags'); + $table->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_08_27_230930_create_club_table.php b/database/migrations/2016_08_27_230930_create_club_table.php index 14a69f7..bb1c59b 100644 --- a/database/migrations/2016_08_27_230930_create_club_table.php +++ b/database/migrations/2016_08_27_230930_create_club_table.php @@ -12,18 +12,15 @@ class CreateClubTable extends Migration */ public function up() { - Schema::create('users', function (Blueprint $table) { + Schema::create('club', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('avatar')->nullable(); - $table->string('powerschool_id')->nullable()->unique(); - $table->string('type'); //社团信息 - $table->text('intro'); - $table->string('is_in_charge'); // 社长ID 多个用 | 分割 - $table->string('is_take_charge'); //负责人ID 多个用 | 分割 + $table->text('self_intro'); + $table->string('is_responsible'); // 社长ID 多个用 | 分割 + $table->string('is_in_charge'); //负责人ID 多个用 | 分割 $table->string('is_hidden'); //只对指定人员开放 - $table->string('created_at'); $table->rememberToken(); $table->timestamps(); diff --git a/database/migrations/2016_09_24_224534_create_class_table.php b/database/migrations/2016_09_24_224534_create_class_table.php index 907c154..2b3c1b6 100644 --- a/database/migrations/2016_09_24_224534_create_class_table.php +++ b/database/migrations/2016_09_24_224534_create_class_table.php @@ -16,7 +16,7 @@ public function up() Schema::create('class', function (Blueprint $table) { $table->increments('id'); $table->string('classname')->unique(); - $table->test('class_intro'); + $table->text('class_intro'); $table->timestamps(); }); } diff --git a/database/migrations/2016_09_24_224912_create_tags_table.php b/database/migrations/2016_09_24_224912_create_tag_table.php similarity index 78% rename from database/migrations/2016_09_24_224912_create_tags_table.php rename to database/migrations/2016_09_24_224912_create_tag_table.php index 1ee7422..7a4e177 100644 --- a/database/migrations/2016_09_24_224912_create_tags_table.php +++ b/database/migrations/2016_09_24_224912_create_tag_table.php @@ -3,7 +3,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateTagsTable extends Migration +class CreateTagTable extends Migration { /** * Run the migrations. @@ -13,10 +13,10 @@ class CreateTagsTable extends Migration public function up() { // - Schema::create('tags', function (Blueprint $table) { + Schema::create('tag', function (Blueprint $table) { $table->increments('id'); $table->string('tag')->unique(); - $table->test('tag_intro'); + $table->text('tag_intro'); $table->timestamps(); }); } From 6ff176daf1021530f701763064225ea9a76672ca Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Thu, 29 Sep 2016 20:29:32 +0800 Subject: [PATCH 05/13] modify some database structure and add model relationship between each tables --- app/Club.php | 14 ++++++++++ app/Http/Controllers/HomeController.php | 6 +++-- app/Http/routes.php | 4 ++- app/Post.php | 20 ++++++++++++++ app/User.php | 11 ++++++++ .../2016_06_20_215205_create_users_table.php | 4 +-- .../2016_08_27_225214_create_post_table.php | 9 ++++--- .../2016_08_27_230247_create_reply_table.php | 2 +- .../2016_08_27_230930_create_club_table.php | 2 +- .../2016_09_24_224534_create_class_table.php | 2 +- .../2016_09_24_224912_create_tag_table.php | 2 +- ...30833_create_associate_club_user_table.php | 6 ++--- database/seeds/DatabaseSeeder.php | 4 ++- database/seeds/PostsSeeder.php | 27 +++++++++++++++++++ database/seeds/UserSeeder.php | 24 +++++++++++++++++ resources/views/welcome.blade.php | 16 ++++++++++- 16 files changed, 135 insertions(+), 18 deletions(-) create mode 100644 app/Club.php create mode 100644 app/Post.php create mode 100644 database/seeds/PostsSeeder.php create mode 100644 database/seeds/UserSeeder.php diff --git a/app/Club.php b/app/Club.php new file mode 100644 index 0000000..2ba95de --- /dev/null +++ b/app/Club.php @@ -0,0 +1,14 @@ +belongsToMany('App\User'); + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cb060b6..852720b 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Requests; +use App\Post; use Illuminate\Http\Request; class HomeController extends Controller @@ -14,7 +15,7 @@ class HomeController extends Controller */ public function __construct() { - $this->middleware('auth'); + } /** @@ -24,6 +25,7 @@ public function __construct() */ public function index() { - return view('home'); + $posts = \App\Post::all(); + return view('welcome')->withPosts($posts); } } diff --git a/app/Http/routes.php b/app/Http/routes.php index f7bc335..da4c31b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -12,9 +12,11 @@ */ Route::get('/', function () { - return view('welcome'); + return view('home'); }); Route::auth(); Route::get('/home', 'HomeController@index'); + +Route::get \ No newline at end of file diff --git a/app/Post.php b/app/Post.php new file mode 100644 index 0000000..d507fc9 --- /dev/null +++ b/app/Post.php @@ -0,0 +1,20 @@ +hasMany('App\Comment'); + } + + public function author() + { + return $this->belongsTo('App\User', 'user_id', 'id'); + } + +} diff --git a/app/User.php b/app/User.php index 8810952..279f6bb 100644 --- a/app/User.php +++ b/app/User.php @@ -33,4 +33,15 @@ public function setPowerschoolIdAttribute($id) { $this->attributes['powerschool_id'] = empty($id) ? NULL : $id; } + + public function roles() + { + return $this->belongsToMany('App\Club', 'user_club', 'user_id', 'club_id'); + } + + public function posts() + { + return $this->hasMany('App\Post'); + } + } diff --git a/database/migrations/2016_06_20_215205_create_users_table.php b/database/migrations/2016_06_20_215205_create_users_table.php index 2f3a848..f0fc913 100644 --- a/database/migrations/2016_06_20_215205_create_users_table.php +++ b/database/migrations/2016_06_20_215205_create_users_table.php @@ -12,7 +12,7 @@ class CreateUsersTable extends Migration */ public function up() { - Schema::create('user', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); @@ -28,7 +28,7 @@ public function up() $table->string('nickname')->nullable()->unique(); $table->string('condition'); $table->text('self_intro')->nullable(); - $table->string('wechat_ID')->unique(); + $table->string('wechat_ID')->nullable()->unique(); $table->string('QQ')->nullable()->unique(); $table->string('alternative_email')->nullable(); $table->string('phone')->nullable()->unique(); diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php index a7ce042..9410a2a 100644 --- a/database/migrations/2016_08_27_225214_create_post_table.php +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -12,16 +12,17 @@ class CreatePostTable extends Migration */ public function up() { - Schema::create('post', function (Blueprint $table) { + Schema::create('posts', function (Blueprint $table) { $table->increments('id'); - $table->string('author_id')->nullable(); + $table->string('user_id'); + $table->string('title'); $table->string('type'); $table->string('club_post_type')->default(1); // 1 是默认 $table->longText('content'); $table->string('tags'); //格式 1|2|3|5, 数字为Tags id $table->date('last_edited_at'); - $table->string('edited_counts'); - $table->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 + $table->string('edited_counts')->nullable(); + $table->string('is_hidden')->nullable(); //which groups of people cannot see 格式 1|2|3|5 $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_08_27_230247_create_reply_table.php b/database/migrations/2016_08_27_230247_create_reply_table.php index 3872488..d591e57 100644 --- a/database/migrations/2016_08_27_230247_create_reply_table.php +++ b/database/migrations/2016_08_27_230247_create_reply_table.php @@ -12,7 +12,7 @@ class CreateReplyTable extends Migration */ public function up() { - Schema::create('reply', function (Blueprint $table) { + Schema::create('replies', function (Blueprint $table) { $table->increments('id'); $table->string('belongs_to')->nullable(); $table->string('type'); diff --git a/database/migrations/2016_08_27_230930_create_club_table.php b/database/migrations/2016_08_27_230930_create_club_table.php index bb1c59b..9005d58 100644 --- a/database/migrations/2016_08_27_230930_create_club_table.php +++ b/database/migrations/2016_08_27_230930_create_club_table.php @@ -12,7 +12,7 @@ class CreateClubTable extends Migration */ public function up() { - Schema::create('club', function (Blueprint $table) { + Schema::create('clubs', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('avatar')->nullable(); diff --git a/database/migrations/2016_09_24_224534_create_class_table.php b/database/migrations/2016_09_24_224534_create_class_table.php index 2b3c1b6..31d1c87 100644 --- a/database/migrations/2016_09_24_224534_create_class_table.php +++ b/database/migrations/2016_09_24_224534_create_class_table.php @@ -13,7 +13,7 @@ class CreateClassTable extends Migration public function up() { // - Schema::create('class', function (Blueprint $table) { + Schema::create('classes', function (Blueprint $table) { $table->increments('id'); $table->string('classname')->unique(); $table->text('class_intro'); diff --git a/database/migrations/2016_09_24_224912_create_tag_table.php b/database/migrations/2016_09_24_224912_create_tag_table.php index 7a4e177..6eafd4b 100644 --- a/database/migrations/2016_09_24_224912_create_tag_table.php +++ b/database/migrations/2016_09_24_224912_create_tag_table.php @@ -13,7 +13,7 @@ class CreateTagTable extends Migration public function up() { // - Schema::create('tag', function (Blueprint $table) { + Schema::create('tags', function (Blueprint $table) { $table->increments('id'); $table->string('tag')->unique(); $table->text('tag_intro'); diff --git a/database/migrations/2016_09_24_230833_create_associate_club_user_table.php b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php index ba04065..df484e8 100644 --- a/database/migrations/2016_09_24_230833_create_associate_club_user_table.php +++ b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php @@ -13,10 +13,10 @@ class CreateAssociateClubUserTable extends Migration public function up() { // - Schema::create('club_user_assoc', function (Blueprint $table) { + Schema::create('club_user', function (Blueprint $table) { $table->increments('id'); - $table->string('club'); - $table->string('user'); + $table->string('club_id'); + $table->string('user_id'); $table->string('level')->default(1); // 1:成员 2:负责人 3:社长 $table->timestamps(); }); diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index e119db6..0a0c0ad 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,8 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UsersTableSeeder::class); + // + $this->call(UserSeeder::class); + $this->call(PostsSeeder::class); } } diff --git a/database/seeds/PostsSeeder.php b/database/seeds/PostsSeeder.php new file mode 100644 index 0000000..760b52e --- /dev/null +++ b/database/seeds/PostsSeeder.php @@ -0,0 +1,27 @@ +delete(); + + for ($i = 0; $i < 10; $i++) { + \App\Post::create([ + 'user_id' => $i, + 'title' => 'post '. $i, + 'tags' => $i, + 'content' => 'content number ' . $i, + + ]); + } + } +} \ No newline at end of file diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php new file mode 100644 index 0000000..bb9cab6 --- /dev/null +++ b/database/seeds/UserSeeder.php @@ -0,0 +1,24 @@ +delete(); + + for ($i = 0; $i < 10; $i++) { + \App\User::create([ + 'name' => 'name' . $i, + 'email' => $i . "@test.com", + ]); + } + } +} \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 06e2217..588a65f 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -8,8 +8,22 @@
Welcome
- Your Application's Landing Page. + @foreach ($posts as $post) +
  • +
    + +

    {{ $post->title}}

    +
    +

    author: {{ $post->author->name }}

    +
    tags: {{ $post->tags }}
    +
    +
    +

    {{ $post->content }}

    +
    +
  • + @endforeach
    + From d54f22cb1a1ad68dad0985353281a35c3ea79569 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Fri, 30 Sep 2016 22:57:50 +0800 Subject: [PATCH 06/13] rebuild database and set model relationship --- app/Comment.php | 20 +++++ app/Http/Controllers/PostController.php | 15 ++++ app/Http/routes.php | 3 +- app/Post.php | 5 +- app/Tag.php | 11 +++ ...016_08_27_230247_create_comment_table.php} | 10 +-- database/seeds/CommentSeeder.php | 26 ++++++ database/seeds/DatabaseSeeder.php | 1 + database/seeds/PostsSeeder.php | 2 +- database/seeds/UserSeeder.php | 2 +- resources/views/post/show.blade.php | 88 +++++++++++++++++++ 11 files changed, 172 insertions(+), 11 deletions(-) create mode 100644 app/Comment.php create mode 100644 app/Http/Controllers/PostController.php create mode 100644 app/Tag.php rename database/migrations/{2016_08_27_230247_create_reply_table.php => 2016_08_27_230247_create_comment_table.php} (75%) create mode 100644 database/seeds/CommentSeeder.php create mode 100644 resources/views/post/show.blade.php diff --git a/app/Comment.php b/app/Comment.php new file mode 100644 index 0000000..16b6d54 --- /dev/null +++ b/app/Comment.php @@ -0,0 +1,20 @@ +belongsTo('App\Post', 'id'); + } + + public function author() + { + return $this->belongsTo('App\User', 'user_id', 'id'); + } + +} diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php new file mode 100644 index 0000000..6a2582c --- /dev/null +++ b/app/Http/Controllers/PostController.php @@ -0,0 +1,15 @@ +withPost(\App\Post::with('hasManyComments')->find($id)); + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index da4c31b..9af8e09 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -18,5 +18,4 @@ Route::auth(); Route::get('/home', 'HomeController@index'); - -Route::get \ No newline at end of file +Route::get('post/{id}', 'PostController@showIndividualPost'); \ No newline at end of file diff --git a/app/Post.php b/app/Post.php index d507fc9..15bd6ba 100644 --- a/app/Post.php +++ b/app/Post.php @@ -7,9 +7,9 @@ class Post extends Model { // - public function comments() + public function hasManyComments() { - return $this->hasMany('App\Comment'); + return $this->hasMany('App\Comment', 'post_id', 'id'); } public function author() @@ -17,4 +17,5 @@ public function author() return $this->belongsTo('App\User', 'user_id', 'id'); } + } diff --git a/app/Tag.php b/app/Tag.php new file mode 100644 index 0000000..c7607ee --- /dev/null +++ b/app/Tag.php @@ -0,0 +1,11 @@ +increments('id'); - $table->string('belongs_to')->nullable(); + $table->string('post_id'); + $table->string('user_id'); $table->string('type'); $table->longText('content'); $table->date('last_edited_at'); $table->string('edited_counts'); - $table->text('tags'); $table->string('is_hidden'); //which groups of people cannot see 格式 1|2|3|5 $table->rememberToken(); $table->timestamps(); @@ -34,6 +34,6 @@ public function up() public function down() { // - Schema::dropIfExists('replys'); + Schema::dropIfExists('comments'); } } diff --git a/database/seeds/CommentSeeder.php b/database/seeds/CommentSeeder.php new file mode 100644 index 0000000..75c9b8b --- /dev/null +++ b/database/seeds/CommentSeeder.php @@ -0,0 +1,26 @@ +delete(); + + for ($i = 1; $i < 10; $i++) { + \App\Comment::create([ + 'user_id' => $i, + 'post_id' => $i, + 'content' => 'content number ' . $i, + + ]); + } + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 0a0c0ad..50ff426 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -14,5 +14,6 @@ public function run() // $this->call(UserSeeder::class); $this->call(PostsSeeder::class); + $this->call(CommentSeeder::class); } } diff --git a/database/seeds/PostsSeeder.php b/database/seeds/PostsSeeder.php index 760b52e..3db0ee8 100644 --- a/database/seeds/PostsSeeder.php +++ b/database/seeds/PostsSeeder.php @@ -14,7 +14,7 @@ public function run() // DB::table('posts')->delete(); - for ($i = 0; $i < 10; $i++) { + for ($i = 1; $i < 10; $i++) { \App\Post::create([ 'user_id' => $i, 'title' => 'post '. $i, diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php index bb9cab6..55794a8 100644 --- a/database/seeds/UserSeeder.php +++ b/database/seeds/UserSeeder.php @@ -14,7 +14,7 @@ public function run() // DB::table('users')->delete(); - for ($i = 0; $i < 10; $i++) { + for ($i = 1; $i < 10; $i++) { \App\User::create([ 'name' => 'name' . $i, 'email' => $i . "@test.com", diff --git a/resources/views/post/show.blade.php b/resources/views/post/show.blade.php new file mode 100644 index 0000000..2749804 --- /dev/null +++ b/resources/views/post/show.blade.php @@ -0,0 +1,88 @@ + + + + + + + + {{$post->title}} - NoticeBoard + + + + + + +
    + +

    + << 返回首页 +

    + +

    {{ $post->title }}

    +
    +
    + {{ $post->updated_at }} +
    +
    + {{ $post->author->name }} +
    +
    +

    + {{ $post->content }} +

    +
    + +
    + + @if (count($errors) > 0) +
    + 操作失败 输入不符合要求

    + {!! implode('
    ', $errors->all()) !!} +
    + @endif + +
    +
    + {!! csrf_field() !!} + +
    + + +
    + +
    +
    + + + +
    + @foreach ($post->hasManyComments as $comment) + +
    +
    +
    {{ $comment->created_at }}
    +
    +
    +

    + {{ $comment->content }} +

    +
    +
    + 回复 +
    +
    + + @endforeach +
    +
    + +
    + + + \ No newline at end of file From 456ee497b02ed5ffbc5227705933f7751d8d3686 Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Fri, 30 Sep 2016 22:58:59 +0800 Subject: [PATCH 07/13] Create README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..92e6db8 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# NoticeBoard + +Rebuild with laravel From 9558833fca3d91b5b9ae6b03f7c897e985a2630c Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Sun, 2 Oct 2016 22:42:45 +0800 Subject: [PATCH 08/13] add auth --- app/Comment.php | 1 + app/Http/Controllers/PostController.php | 23 +++++++++++++++++-- app/Http/routes.php | 12 +++++++++- .../2016_08_27_225214_create_post_table.php | 3 ++- resources/views/login_required.blade.php | 17 ++++++++++++++ resources/views/post/show.blade.php | 7 ++++++ 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 resources/views/login_required.blade.php diff --git a/app/Comment.php b/app/Comment.php index 16b6d54..d5f67d5 100644 --- a/app/Comment.php +++ b/app/Comment.php @@ -6,6 +6,7 @@ class Comment extends Model { + protected $fillable = ['content', 'post_id', 'club_post_type', 'tags', 'title']; // public function post() { diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php index 6a2582c..514cabe 100644 --- a/app/Http/Controllers/PostController.php +++ b/app/Http/Controllers/PostController.php @@ -1,15 +1,34 @@ value('is_login') == 1) { + return view('login_required')->withErrors('本主题需要登录后查看'); + } return view('post/show')->withPost(\App\Post::with('hasManyComments')->find($id)); } + + public function getReply(Request $request){ + + if ($user = $request->user()){ + if (\App\Comment::create($request->all(), ['user_id' => $user->id ])){ + return redirect()->back(); + } else { + return redirect()->back()->withInput()->withErrors('评论发表失败!'); + } + } else { + return view('login_required')->withErrors('回复需要登录'); + } + + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 9af8e09..d9d13f4 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -15,7 +15,17 @@ return view('home'); }); +// 认证路由... +Route::get('auth/login', 'Auth\AuthController@getLogin'); +Route::post('auth/login', 'Auth\AuthController@postLogin'); +Route::get('auth/logout', 'Auth\AuthController@getLogout'); + +// 注册路由... +Route::get('auth/register', 'Auth\AuthController@getRegister'); +Route::post('auth/register', 'Auth\AuthController@postRegister'); + Route::auth(); Route::get('/home', 'HomeController@index'); -Route::get('post/{id}', 'PostController@showIndividualPost'); \ No newline at end of file +Route::get('post/{id}', 'PostController@showIndividualPost'); +Route::post('comment', 'PostController@getReply'); \ No newline at end of file diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php index 9410a2a..a113fd9 100644 --- a/database/migrations/2016_08_27_225214_create_post_table.php +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -17,10 +17,11 @@ public function up() $table->string('user_id'); $table->string('title'); $table->string('type'); + $table->string('is_login')->default(0); $table->string('club_post_type')->default(1); // 1 是默认 $table->longText('content'); $table->string('tags'); //格式 1|2|3|5, 数字为Tags id - $table->date('last_edited_at'); + $table->date('last_edited_at')->nullable(); $table->string('edited_counts')->nullable(); $table->string('is_hidden')->nullable(); //which groups of people cannot see 格式 1|2|3|5 $table->rememberToken(); diff --git a/resources/views/login_required.blade.php b/resources/views/login_required.blade.php new file mode 100644 index 0000000..3ccd31f --- /dev/null +++ b/resources/views/login_required.blade.php @@ -0,0 +1,17 @@ +@extends('layouts.app') + +@section('content') +
    +
    +
    +
    +
    Dashboard
    + +
    + {!! implode('
    ', $errors->all()) !!} +
    +
    +
    +
    +
    +@endsection diff --git a/resources/views/post/show.blade.php b/resources/views/post/show.blade.php index 2749804..38f5e2c 100644 --- a/resources/views/post/show.blade.php +++ b/resources/views/post/show.blade.php @@ -45,6 +45,10 @@
    {!! csrf_field() !!} +
    + + +
    @@ -62,12 +66,15 @@ function reply(a) {
    +
    @foreach ($post->hasManyComments as $comment)
    {{ $comment->created_at }}
    +
    {{$count ++}}楼
    +

    {{ $comment->content }} From 0564d440a4ecba3addd5cdde17e412261fa7cf1e Mon Sep 17 00:00:00 2001 From: NeverBehave Date: Mon, 3 Oct 2016 13:30:59 +0800 Subject: [PATCH 09/13] rebuild database and add auth --- app/Http/Controllers/PostController.php | 22 ++++++++---- app/Http/routes.php | 18 ++++------ app/Policies/PostPolicy.php | 28 +++++++++++++++ app/Providers/AuthServiceProvider.php | 6 ++++ .../2016_06_20_215205_create_users_table.php | 3 +- .../2016_08_27_225214_create_post_table.php | 1 - .../2016_09_24_224534_create_class_table.php | 2 +- ...30833_create_associate_club_user_table.php | 2 +- ...16_10_03_124443_create_like_post_table.php | 34 +++++++++++++++++++ resources/views/post/show.blade.php | 11 +++--- 10 files changed, 100 insertions(+), 27 deletions(-) create mode 100644 app/Policies/PostPolicy.php create mode 100644 database/migrations/2016_10_03_124443_create_like_post_table.php diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php index 514cabe..c4f55f1 100644 --- a/app/Http/Controllers/PostController.php +++ b/app/Http/Controllers/PostController.php @@ -6,29 +6,39 @@ use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Auth; +use App\Post; +use App\Comment; + class PostController extends Controller { // public function showIndividualPost($id){ - if (!Auth::check() && \App\Post::where('id', $id)->value('is_login') == 1) { + if (!Auth::check() && Post::where('id', $id)->value('is_login') == 1) { return view('login_required')->withErrors('本主题需要登录后查看'); } - return view('post/show')->withPost(\App\Post::with('hasManyComments')->find($id)); + return view('post/show')->withPost(Post::with('hasManyComments')->find($id)); } public function getReply(Request $request){ if ($user = $request->user()){ - if (\App\Comment::create($request->all(), ['user_id' => $user->id ])){ - return redirect()->back(); - } else { - return redirect()->back()->withInput()->withErrors('评论发表失败!'); + if (!$request->has('content')){ + return redirect()->back()->withInput()->withErrors('评论为空!'); + } + if ($comment = Comment::create($request->all())){ + $comment->user_id = $user->id; + if ($comment->save()) { + return redirect()->back(); + } else { + $comment->delete(); // 防止错误 + } } } else { return view('login_required')->withErrors('回复需要登录'); } + return redirect()->back()->withInput()->withErrors('评论发表失败!'); } } diff --git a/app/Http/routes.php b/app/Http/routes.php index d9d13f4..070e93b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -11,21 +11,17 @@ | */ -Route::get('/', function () { - return view('home'); -}); +Route::get('/', 'HomeController@index'); + // 认证路由... -Route::get('auth/login', 'Auth\AuthController@getLogin'); -Route::post('auth/login', 'Auth\AuthController@postLogin'); -Route::get('auth/logout', 'Auth\AuthController@getLogout'); +Route::auth(); +Route::get('/logout', 'Auth\AuthController@getLogout'); // 注册路由... -Route::get('auth/register', 'Auth\AuthController@getRegister'); -Route::post('auth/register', 'Auth\AuthController@postRegister'); - -Route::auth(); +Route::get('/register', 'Auth\AuthController@getRegister'); +Route::post('/register', 'Auth\AuthController@postRegister'); -Route::get('/home', 'HomeController@index'); +//帖子... Route::get('post/{id}', 'PostController@showIndividualPost'); Route::post('comment', 'PostController@getReply'); \ No newline at end of file diff --git a/app/Policies/PostPolicy.php b/app/Policies/PostPolicy.php new file mode 100644 index 0000000..2fc7a18 --- /dev/null +++ b/app/Policies/PostPolicy.php @@ -0,0 +1,28 @@ +id === $post->user_id; + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 57d88ea..fad03e4 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Auth\Access\Gate as GateContract; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Auth; class AuthServiceProvider extends ServiceProvider { @@ -14,6 +15,7 @@ class AuthServiceProvider extends ServiceProvider */ protected $policies = [ 'App\Model' => 'App\Policies\ModelPolicy', + 'Post::class' => 'PostPolicy::class', ]; /** @@ -26,6 +28,10 @@ public function boot(GateContract $gate) { $this->registerPolicies($gate); + $gate->define('comment', function ($user, $post) { + return Auth::check(); + }); + // } } diff --git a/database/migrations/2016_06_20_215205_create_users_table.php b/database/migrations/2016_06_20_215205_create_users_table.php index f0fc913..9f58bdb 100644 --- a/database/migrations/2016_06_20_215205_create_users_table.php +++ b/database/migrations/2016_06_20_215205_create_users_table.php @@ -18,7 +18,8 @@ public function up() $table->string('email')->unique(); $table->string('password'); $table->string('class')->nullable(); - $table->string('grade'); + $table->string('grade'); // xx学年 + $table->string('active')->default(0); // 0 or 1 $table->string('avatar')->nullable(); $table->string('powerschool_id')->nullable()->unique(); $table->string('type'); // 数字为用户身份: 1 public, 2 admin diff --git a/database/migrations/2016_08_27_225214_create_post_table.php b/database/migrations/2016_08_27_225214_create_post_table.php index a113fd9..2690672 100644 --- a/database/migrations/2016_08_27_225214_create_post_table.php +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -20,7 +20,6 @@ public function up() $table->string('is_login')->default(0); $table->string('club_post_type')->default(1); // 1 是默认 $table->longText('content'); - $table->string('tags'); //格式 1|2|3|5, 数字为Tags id $table->date('last_edited_at')->nullable(); $table->string('edited_counts')->nullable(); $table->string('is_hidden')->nullable(); //which groups of people cannot see 格式 1|2|3|5 diff --git a/database/migrations/2016_09_24_224534_create_class_table.php b/database/migrations/2016_09_24_224534_create_class_table.php index 31d1c87..0327d53 100644 --- a/database/migrations/2016_09_24_224534_create_class_table.php +++ b/database/migrations/2016_09_24_224534_create_class_table.php @@ -29,6 +29,6 @@ public function up() public function down() { // - Schema::dropIfExists('class'); + Schema::dropIfExists('classes'); } } diff --git a/database/migrations/2016_09_24_230833_create_associate_club_user_table.php b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php index df484e8..6a1c104 100644 --- a/database/migrations/2016_09_24_230833_create_associate_club_user_table.php +++ b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php @@ -30,6 +30,6 @@ public function up() public function down() { // - Schema::dropIfExists('asscociate_club_user'); + Schema::dropIfExists('club_user'); } } diff --git a/database/migrations/2016_10_03_124443_create_like_post_table.php b/database/migrations/2016_10_03_124443_create_like_post_table.php new file mode 100644 index 0000000..e7fe48a --- /dev/null +++ b/database/migrations/2016_10_03_124443_create_like_post_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('post_id'); + $table->string('user_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::dropIfExists('like_post'); + } +} diff --git a/resources/views/post/show.blade.php b/resources/views/post/show.blade.php index 38f5e2c..023cfba 100644 --- a/resources/views/post/show.blade.php +++ b/resources/views/post/show.blade.php @@ -41,14 +41,11 @@

    @endif + @can('comment', $post)
    {!! csrf_field() !!} -
    - - -
    @@ -56,7 +53,9 @@
    - + @else +
    如需回复请先登录
    + @endcan