diff --git a/.gitignore b/.gitignore index f6aa8c6..b381b77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.phpstorm.meta.php +.DS.Store +_ide_helper.php /vendor /node_modules /public/storage @@ -10,4 +13,4 @@ Homestead.json /material-foundation/.sass-cache .phpstorm.meta.php _ide_helper.php -/public/build \ No newline at end of file +/public/build diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index de0b3b7..e67cd51 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -3,7 +3,7 @@ /** * PhpStorm Meta file, to provide autocomplete information for PhpStorm - * Generated on 2016-07-27. + * Generated on 2016-10-03. * * @author Barry vd. Heuvel * @see https://github.com/barryvdh/laravel-ide-helper diff --git a/README.md b/README.md index 9dfcc1d..92e6db8 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# NoticeBoard \ No newline at end of file +# NoticeBoard + +Rebuild with laravel diff --git a/_ide_helper.php b/_ide_helper.php index 6690d1b..3f48be4 100644 --- a/_ide_helper.php +++ b/_ide_helper.php @@ -1,7 +1,7 @@ * @see https://github.com/barryvdh/laravel-ide-helper @@ -1627,17 +1627,6 @@ public static function viaRemember(){ return \Illuminate\Auth\SessionGuard::viaRemember(); } - /** - * Determine if the current user is authenticated. - * - * @return \App\User - * @throws \Illuminate\Auth\AuthenticationException - * @static - */ - public static function authenticate(){ - return \Illuminate\Auth\SessionGuard::authenticate(); - } - /** * Determine if the current user is authenticated. * @@ -1658,6 +1647,17 @@ public static function guest(){ return \Illuminate\Auth\SessionGuard::guest(); } + /** + * Determine if the current user is authenticated. + * + * @return \App\User + * @throws \Illuminate\Auth\AuthenticationException + * @static + */ + public static function authenticate(){ + return \Illuminate\Auth\SessionGuard::authenticate(); + } + } @@ -3876,7 +3876,7 @@ public static function applyScopes(){ /** * Get the underlying query builder instance. * - * @return \Illuminate\Database\Query\Builder|static + * @return \Illuminate\Database\Query\Builder * @static */ public static function getQuery(){ @@ -4461,6 +4461,33 @@ public static function orWhereDate($column, $operator, $value){ return \Illuminate\Database\Query\Builder::orWhereDate($column, $operator, $value); } + /** + * Add a "where time" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + * @static + */ + public static function whereTime($column, $operator, $value, $boolean = 'and'){ + return \Illuminate\Database\Query\Builder::whereTime($column, $operator, $value, $boolean); + } + + /** + * Add an "or where time" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @return \Illuminate\Database\Query\Builder|static + * @static + */ + public static function orWhereTime($column, $operator, $value){ + return \Illuminate\Database\Query\Builder::orWhereTime($column, $operator, $value); + } + /** * Add a "where day" statement to the query. * @@ -4816,7 +4843,7 @@ public static function count($columns = '*'){ * Retrieve the minimum value of a given column. * * @param string $column - * @return float|int + * @return mixed * @static */ public static function min($column){ @@ -4827,7 +4854,7 @@ public static function min($column){ * Retrieve the maximum value of a given column. * * @param string $column - * @return float|int + * @return mixed * @static */ public static function max($column){ @@ -4838,7 +4865,7 @@ public static function max($column){ * Retrieve the sum of the values of a given column. * * @param string $column - * @return float|int + * @return mixed * @static */ public static function sum($column){ @@ -4849,7 +4876,7 @@ public static function sum($column){ * Retrieve the average of the values of a given column. * * @param string $column - * @return float|int + * @return mixed * @static */ public static function avg($column){ @@ -4860,7 +4887,7 @@ public static function avg($column){ * Alias for the "avg" method. * * @param string $column - * @return float|int + * @return mixed * @static */ public static function average($column){ @@ -4872,13 +4899,25 @@ public static function average($column){ * * @param string $function * @param array $columns - * @return float|int + * @return mixed * @static */ public static function aggregate($function, $columns = array()){ return \Illuminate\Database\Query\Builder::aggregate($function, $columns); } + /** + * Execute a numeric aggregate function on the database. + * + * @param string $function + * @param array $columns + * @return float|int + * @static + */ + public static function numericAggregate($function, $columns = array()){ + return \Illuminate\Database\Query\Builder::numericAggregate($function, $columns); + } + /** * Insert a new record into the database. * 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/Comment.php b/app/Comment.php new file mode 100644 index 0000000..d5f67d5 --- /dev/null +++ b/app/Comment.php @@ -0,0 +1,21 @@ +belongsTo('App\Post', 'id'); + } + + public function author() + { + return $this->belongsTo('App\User', 'user_id', 'id'); + } + +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cb060b6..b99c08a 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 = Post::with('hasManyComments','tagged')->orderBy('updated_at', 'desc')->get(); + return view('welcome')->withPosts($posts); } } diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php new file mode 100644 index 0000000..96eda89 --- /dev/null +++ b/app/Http/Controllers/PostController.php @@ -0,0 +1,78 @@ +value('is_login') == 1) { + return view('login_required')->withErrors('本主题需要登录后查看'); + } + return view('post/show')->withPost(Post::with('hasManyComments','tagged')->find($id)); + } + + public function getReply(Request $request){ + + if ($user = $request->user()) { + if (!$request->has('content')) { + return redirect()->back()->withInput()->withErrors('评论为空!'); + } + if ($comment = new Comment()) { + $comment->user_id = $user->id; + $comment->content = $request->content; + $comment->post_id = $request->post_id; + if (!$comment->save()) { + return redirect()->back()->withInput()->withErrors('评论发表失败!'); + } + $post = Post::where('id', $request->post_id)->first(); + $post->last_user = $user->id; + if (!$post->save()) { + return redirect()->back()->withInput()->withErrors('更新状态失败!'); + } + return redirect()->back(); + } else { + return view('login_required')->withErrors('回复需要登录'); + } + } + } + + public function createSite(){ + return view('post/create'); + } + + public function createNewPost(Request $request) + { + if ($user = $request->user()){ + if (!$request->has('content')){ + return redirect()->back()->withInput()->withErrors('内容为空!'); + } + if ($post = new Post()){ + $post->user_id = $user->id; + $post->content = $request->content; + $post->title = $request->title; + $post->save(); // tags need post id ! + $post->tag($request->tags); + if ($post->save()) { + return redirect()->back(); + } else { + $post->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 f7bc335..397807a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -11,10 +11,32 @@ | */ -Route::get('/', function () { - return view('welcome'); -}); +Route::get('/', 'HomeController@index'); + +// 认证路由... Route::auth(); +Route::get('/logout', 'Auth\AuthController@getLogout'); + +// 注册路由... +Route::get('/register', 'Auth\AuthController@getRegister'); +Route::post('/register', 'Auth\AuthController@postRegister'); + +//帖子... +Route::get('/post/{id}', 'PostController@showIndividualPost'); +Route::post('comment', 'PostController@getReply'); +Route::post('/post', 'PostController@createNewPost'); +Route::get('/post', 'PostController@createSite'); + +//功能划分 +Route::get('/more', 'SectionController@showAllSections'); +Route::get('/more/{function}', 'SectionController@showSpecificFunction'); +Route::post('/more/{function}', 'SectionController@runSpecificFunction'); + +//个人中心 +Route::get('/profile', 'UserController@showMyself'); +Route::get('/profile/{nickname}', 'UserController@showSpecificProfile'); -Route::get('/home', 'HomeController@index'); +//社区 +Route::get('/clubs', 'ClubController@showAllClubs'); +Route::get('/clubs/{clubname}', 'ClubController@showSpecificClub'); \ 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/Post.php b/app/Post.php new file mode 100644 index 0000000..5fc7e4f --- /dev/null +++ b/app/Post.php @@ -0,0 +1,27 @@ +hasMany('App\Comment', 'post_id', 'id'); + } + + public function getAuthor() + { + return $this->belongsTo('App\User', 'user_id', 'id'); + } + + public function getLast_user() + { + return $this->belongsTo('App\User', 'last_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/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/composer.json b/composer.json index 783ef43..b2d526f 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "type": "project", "require": { "php": ">=5.5.9", - "laravel/framework": "5.2.*" + "laravel/framework": "5.2.*", + "rtconner/laravel-tagging": "~2.2" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 8e212d9..c80cd93 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "a84cdb63fcfde20e6a4c7aaae48c4b51", - "content-hash": "a71b145361dbdaedd3b94de2aa978839", + "hash": "0b138aefa4b58edd28c3032f6c88aab2", + "content-hash": "843dc465838d85bd40cf134f8962d4f6", "packages": [ { "name": "classpreloader/classpreloader", @@ -897,6 +897,61 @@ ], "time": "2016-03-09 05:03:14" }, + { + "name": "rtconner/laravel-tagging", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/rtconner/laravel-tagging.git", + "reference": "ce928fbd43ed011847e0c245033b7447f54bf0c6" + }, + "dist": { + "type": "zip", + "url": "https://packagist.phpcomposer.com/files/rtconner/laravel-tagging/ce928fbd43ed011847e0c245033b7447f54bf0c6.zip", + "reference": "ce928fbd43ed011847e0c245033b7447f54bf0c6", + "shasum": "" + }, + "require": { + "illuminate/database": ">= 5.0", + "illuminate/support": ">= 5.0", + "php": ">=5.5.0" + }, + "require-dev": { + "mockery/mockery": "~0.9", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "~4.0", + "vlucas/phpdotenv": "~2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Conner\\Tagging\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Robert Conner", + "email": "rtconner@smarter.bz" + } + ], + "description": "Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable.", + "homepage": "https://smartersoftware.net/packages/laravel-tagging-taggable", + "keywords": [ + "Taggable", + "eloquent", + "laravel", + "laravel5", + "tag", + "tagged", + "tagging", + "tags" + ], + "time": "2016-09-12 21:50:32" + }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.3", @@ -2496,6 +2551,49 @@ "homepage": "http://laravel.com", "time": "2016-06-09 01:54:11" }, + { + "name": "illuminate/container", + "version": "v5.2.45", + "source": { + "type": "git", + "url": "https://github.com/illuminate/container.git", + "reference": "5139cebc8293b6820b91aef6f4b4e18bde33c9b2" + }, + "dist": { + "type": "zip", + "url": "https://packagist.phpcomposer.com/files/illuminate/container/5139cebc8293b6820b91aef6f4b4e18bde33c9b2.zip", + "reference": "5139cebc8293b6820b91aef6f4b4e18bde33c9b2", + "shasum": "" + }, + "require": { + "illuminate/contracts": "5.2.*", + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Container\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Container package.", + "homepage": "http://laravel.com", + "time": "2016-08-01 13:49:14" + }, { "name": "illuminate/contracts", "version": "v5.2.37", @@ -2538,6 +2636,66 @@ "homepage": "http://laravel.com", "time": "2016-05-31 21:36:13" }, + { + "name": "illuminate/database", + "version": "v5.2.45", + "source": { + "type": "git", + "url": "https://github.com/illuminate/database.git", + "reference": "4a70c0598ed41d18a99f23c12be4e22b5006d30a" + }, + "dist": { + "type": "zip", + "url": "https://packagist.phpcomposer.com/files/illuminate/database/4a70c0598ed41d18a99f23c12be4e22b5006d30a.zip", + "reference": "4a70c0598ed41d18a99f23c12be4e22b5006d30a", + "shasum": "" + }, + "require": { + "illuminate/container": "5.2.*", + "illuminate/contracts": "5.2.*", + "illuminate/support": "5.2.*", + "nesbot/carbon": "~1.20", + "php": ">=5.5.9" + }, + "suggest": { + "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).", + "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", + "illuminate/console": "Required to use the database commands (5.2.*).", + "illuminate/events": "Required to use the observers with Eloquent (5.2.*).", + "illuminate/filesystem": "Required to use the migrations (5.2.*).", + "illuminate/pagination": "Required to paginate the result set (5.2.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Database\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Database package.", + "homepage": "http://laravel.com", + "keywords": [ + "database", + "laravel", + "orm", + "sql" + ], + "time": "2016-08-25 07:01:20" + }, { "name": "illuminate/filesystem", "version": "v5.2.37", diff --git a/config/app.php b/config/app.php index 30456f0..e92a30c 100644 --- a/config/app.php +++ b/config/app.php @@ -158,6 +158,10 @@ App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + /* Tags Provider + */ + \Conner\Tagging\Providers\TaggingServiceProvider::class, + ], /* diff --git a/config/tagging.php b/config/tagging.php new file mode 100644 index 0000000..62d14df --- /dev/null +++ b/config/tagging.php @@ -0,0 +1,31 @@ + 'integer', // 'string' or 'integer' + + // Value of are passed through this before save of tags + 'normalizer' => '\Conner\Tagging\Util::slug', + + // Display value of tags are passed through (for front end display) + 'displayer' => '\Illuminate\Support\Str::title', + + // Database connection for Conner\Taggable\Tag model to use +// 'connection' => 'mysql', + + // When deleting a model, remove all the tags first + 'untag_on_delete' => true, + + // Auto-delete unused tags from the 'tags' database table (when they are used zero times) + 'delete_unused_tags'=>true, + + // Model to use to store the tags in the database + 'tag_model'=>'\Conner\Tagging\Model\Tag', + + // Delimiter used within tags + 'delimiter' => '-', + + // Model to use for the relation between tags and tagged records + 'tagged_model' => '\Conner\Tagging\Model\Tagged', +]; diff --git a/database/migrations/2014_01_07_073615_create_tagged_table.php b/database/migrations/2014_01_07_073615_create_tagged_table.php new file mode 100644 index 0000000..5864015 --- /dev/null +++ b/database/migrations/2014_01_07_073615_create_tagged_table.php @@ -0,0 +1,25 @@ +increments('id'); + if(config('tagging.primary_keys_type') == 'string') { + $table->string('taggable_id', 36)->index(); + } else { + $table->integer('taggable_id')->unsigned()->index(); + } + $table->string('taggable_type', 255)->index(); + $table->string('tag_name', 255); + $table->string('tag_slug', 255)->index(); + }); + } + + public function down() { + Schema::drop('tagging_tagged'); + } +} diff --git a/database/migrations/2014_01_07_073615_create_tags_table.php b/database/migrations/2014_01_07_073615_create_tags_table.php new file mode 100644 index 0000000..ea25960 --- /dev/null +++ b/database/migrations/2014_01_07_073615_create_tags_table.php @@ -0,0 +1,23 @@ +increments('id'); + $table->string('slug', 255)->index(); + $table->string('name', 255); + $table->boolean('suggest')->default(false); + $table->integer('count')->unsigned()->default(0); // count of how many times this tag was used + }); + } + + public function down() + { + Schema::drop('tagging_tags'); + } +} 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 718ddce..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,9 +18,21 @@ public function up() $table->string('email')->unique(); $table->string('password'); $table->string('class')->nullable(); + $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'); + $table->string('type'); // 数字为用户身份: 1 public, 2 admin + $table->string('created_counts')->default(0); //累计发言数 + $table->string('identity'); // 用|分割不同权限,对应到assoc表单中的id + //个人信息 + $table->string('nickname')->nullable()->unique(); + $table->string('condition'); + $table->text('self_intro')->nullable(); + $table->string('wechat_ID')->nullable()->unique(); + $table->string('QQ')->nullable()->unique(); + $table->string('alternative_email')->nullable(); + $table->string('phone')->nullable()->unique(); $table->rememberToken(); $table->timestamps(); }); @@ -33,6 +45,6 @@ public function up() */ public function down() { - Schema::drop('users'); + Schema::dropIfExists('users'); } } diff --git a/database/migrations/2016_06_29_073615_create_tag_groups_table.php b/database/migrations/2016_06_29_073615_create_tag_groups_table.php new file mode 100644 index 0000000..b274f43 --- /dev/null +++ b/database/migrations/2016_06_29_073615_create_tag_groups_table.php @@ -0,0 +1,21 @@ +increments('id'); + $table->string('slug', 255)->index(); + $table->string('name', 255); + }); + } + + public function down() + { + Schema::drop('tagging_tag_groups'); + } +} diff --git a/database/migrations/2016_06_29_073615_update_tags_table.php b/database/migrations/2016_06_29_073615_update_tags_table.php new file mode 100644 index 0000000..10f5b71 --- /dev/null +++ b/database/migrations/2016_06_29_073615_update_tags_table.php @@ -0,0 +1,26 @@ +integer('tag_group_id')->unsigned()->nullable()->after('id'); + $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups'); + }); + + } + + + public function down() + { + Schema::table('tagging_tags', function ($table) { + $table->dropForeign('tagging_tags_tag_group_id_foreign'); + $table->dropColumn('tag_group_id'); + }); + } +} 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..9d25596 --- /dev/null +++ b/database/migrations/2016_08_27_225214_create_post_table.php @@ -0,0 +1,43 @@ +increments('id'); + $table->string('user_id'); + $table->string('last_user')->nullable(); + $table->string('title'); + $table->string('type')->default(1); + $table->string('is_login')->default(0); + // $table->string('tags'); no need, https://github.com/rtconner/laravel-tagging does the same job + $table->string('club_post_type')->default(0); // 0 是默认 + $table->longText('content'); + $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(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::dropIfExists('posts'); + } +} diff --git a/database/migrations/2016_08_27_230247_create_comment_table.php b/database/migrations/2016_08_27_230247_create_comment_table.php new file mode 100644 index 0000000..8d54615 --- /dev/null +++ b/database/migrations/2016_08_27_230247_create_comment_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('post_id'); + $table->string('user_id'); + $table->string('type')->default(1); + $table->longText('content'); + $table->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::dropIfExists('comments'); + } +} 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..9005d58 --- /dev/null +++ b/database/migrations/2016_08_27_230930_create_club_table.php @@ -0,0 +1,40 @@ +increments('id'); + $table->string('name'); + $table->string('avatar')->nullable(); + //社团信息 + $table->text('self_intro'); + $table->string('is_responsible'); // 社长ID 多个用 | 分割 + $table->string('is_in_charge'); //负责人ID 多个用 | 分割 + $table->string('is_hidden'); //只对指定人员开放 + + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + 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..0327d53 --- /dev/null +++ b/database/migrations/2016_09_24_224534_create_class_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('classname')->unique(); + $table->text('class_intro'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + 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 new file mode 100644 index 0000000..6a1c104 --- /dev/null +++ b/database/migrations/2016_09_24_230833_create_associate_club_user_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('club_id'); + $table->string('user_id'); + $table->string('level')->default(1); // 1:成员 2:负责人 3:社长 + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + 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/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 e119db6..6f5442b 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,10 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UsersTableSeeder::class); + // + $this->call(UserSeeder::class); + $this->call(PostsSeeder::class); + $this->call(CommentSeeder::class); + $this->call(TagSeeder::class); } } diff --git a/database/seeds/PostsSeeder.php b/database/seeds/PostsSeeder.php new file mode 100644 index 0000000..3db0ee8 --- /dev/null +++ b/database/seeds/PostsSeeder.php @@ -0,0 +1,27 @@ +delete(); + + for ($i = 1; $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..55794a8 --- /dev/null +++ b/database/seeds/UserSeeder.php @@ -0,0 +1,24 @@ +delete(); + + for ($i = 1; $i < 10; $i++) { + \App\User::create([ + 'name' => 'name' . $i, + 'email' => $i . "@test.com", + ]); + } + } +} \ 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). 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/create.blade.php b/resources/views/post/create.blade.php new file mode 100644 index 0000000..fc59cea --- /dev/null +++ b/resources/views/post/create.blade.php @@ -0,0 +1,19 @@ + +
+ {!! csrf_field() !!} +
+
+ + +
+
+ + +
+ + +
+ +
+ + diff --git a/resources/views/post/show.blade.php b/resources/views/post/show.blade.php new file mode 100644 index 0000000..3f5fe54 --- /dev/null +++ b/resources/views/post/show.blade.php @@ -0,0 +1,99 @@ + + + + + + + + {{$post->title}} - NoticeBoard + + + + + + +
+ +

+ << 返回首页 +

+ +

{{ $post->title }}

+
+
+ updated at: {{ $post->updated_at }} +
+
+ author:{{ $post->getAuthor->name }} +
+ @foreach ($post->tags as $tag) +
+
tags:{{$tag->name}}
+
+ @endforeach +
+

+ {{ $post->content }} +

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

+ {!! implode('
', $errors->all()) !!} +
+ @endif + + @can('comment', $post) +
+
+ {!! csrf_field() !!} + +
+ + +
+ +
+
+ @else +
如需回复请先登录
+ @endcan + + +
+
+ @foreach ($post->hasManyComments as $comment) + +
+
+
{{ $comment->created_at }}
+
+
{{$count ++}}楼
+
+
+

+ {{ $comment->content }} +

+
+
+ 回复 +
+
+ + @endforeach +
+
+ + + + + \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 06e2217..54c0bdf 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -5,11 +5,42 @@
-
Welcome
+
Lattest News
- Your Application's Landing Page. + @foreach ($posts as $post) +
+
+

+ {{ $post->title}} +

+

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

+ +

创建时间: {{$post->created_at}}

+
+

+ {{$post->content}} +

+ +

累计回复:{{$post->hasManyComments->count()}}

+ @if ($post->last_user != NULL) +

最后一次操作:{{$post->updated_at}}

+

用户:{{$post->getLast_user->name}}

+ @endif +
+

+ @foreach($post->tags as $tag) + {{$tag->name}} + @endforeach + +

+
+ @endforeach +
+ +
+