@@ -24,6 +24,6 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function broadcastOn() |
| 26 | 26 | { |
| 27 | - return ['laravel-forum']; |
|
| 27 | + return [ 'laravel-forum' ]; |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -19,9 +19,9 @@ |
||
| 19 | 19 | |
| 20 | 20 | $script = $dom->getElementsByTagName('script'); |
| 21 | 21 | |
| 22 | - $remove = []; |
|
| 22 | + $remove = [ ]; |
|
| 23 | 23 | foreach ($script as $item) { |
| 24 | - $remove[] = $item; |
|
| 24 | + $remove[ ] = $item; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | foreach ($remove as $item) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $post = ForumPost::create($data); |
| 83 | 83 | |
| 84 | 84 | event(new PostCreated($post, $user)); |
| 85 | - return redirect()->route('laravel-forum.view.post', [$forum_id , $post->id]); |
|
| 85 | + return redirect()->route('laravel-forum.view.post', [ $forum_id, $post->id ]); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function forumReplyStore() |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | ]; |
| 104 | 104 | |
| 105 | 105 | if (!ForumReply::valid($data)) { |
| 106 | - return redirect()->route('laravel-forum.view.post', [$forum_id, $post_id]); |
|
| 106 | + return redirect()->route('laravel-forum.view.post', [ $forum_id, $post_id ]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $reply = ForumReply::create($data); |
| 110 | 110 | |
| 111 | 111 | event(new PostReply($reply, $user)); |
| 112 | - return redirect()->route('laravel-forum.view.post', [$forum_id, $post_id]); |
|
| 112 | + return redirect()->route('laravel-forum.view.post', [ $forum_id, $post_id ]); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | private function adminCheck() |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use \Schema; |
| 7 | 7 | |
| 8 | 8 | use Illuminate\Http\Request; |
| 9 | - |
|
| 10 | 9 | use Taskforcedev\LaravelForum\Forum; |
| 11 | 10 | use Taskforcedev\LaravelForum\ForumCategory; |
| 12 | 11 | use Taskforcedev\LaravelForum\ForumPost; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | $data = $this->buildData(); |
| 28 | - $data['forum'] = $forum; |
|
| 28 | + $data[ 'forum' ] = $forum; |
|
| 29 | 29 | |
| 30 | 30 | return view('laravel-forum::forum.forum', $data); |
| 31 | 31 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $data = $this->buildData(); |
| 42 | - $data['forum'] = $forum; |
|
| 42 | + $data[ 'forum' ] = $forum; |
|
| 43 | 43 | |
| 44 | 44 | return view('laravel-forum::forum.createPost', $data); |
| 45 | 45 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $post = ForumPost::with('replies')->where('id', $post_id)->firstOrFail(); |
| 51 | 51 | |
| 52 | 52 | $data = $this->buildData(); |
| 53 | - $data['post'] = $post; |
|
| 53 | + $data[ 'post' ] = $post; |
|
| 54 | 54 | |
| 55 | 55 | return view('laravel-forum::forum.thread', $data); |
| 56 | 56 | } catch (Exception $e) { |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function broadcastOn() |
| 26 | 26 | { |
| 27 | - return ['laravel-forum']; |
|
| 27 | + return [ 'laravel-forum' ]; |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $data = $this->buildData(); |
| 27 | 27 | |
| 28 | - $data['counts'] = [ |
|
| 28 | + $data[ 'counts' ] = [ |
|
| 29 | 29 | 'forum' => (new Forum)->getCount(), |
| 30 | 30 | 'category' => (new ForumCategory)->getCount(), |
| 31 | 31 | 'post' => (new ForumPost)->getCount(), |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $data = $this->buildData(); |
| 48 | - $data['categories'] = ForumCategory::all(); |
|
| 49 | - $data['forums'] = Forum::orderBy('category_id')->get(); |
|
| 48 | + $data[ 'categories' ] = ForumCategory::all(); |
|
| 49 | + $data[ 'forums' ] = Forum::orderBy('category_id')->get(); |
|
| 50 | 50 | return view('laravel-forum::admin/forums', $data); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $data = $this->buildData(); |
| 63 | - $data['categories'] = ForumCategory::all(); |
|
| 63 | + $data[ 'categories' ] = ForumCategory::all(); |
|
| 64 | 64 | return view('laravel-forum::admin/categories', $data); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $data = $this->buildData(); |
| 74 | - $data['categories'] = ForumCategory::all(); |
|
| 74 | + $data[ 'categories' ] = ForumCategory::all(); |
|
| 75 | 75 | return view('laravel-forum::admin.forum.create', $data); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php namespace Taskforcedev\LaravelForum\Http\Controllers; |
| 2 | 2 | |
| 3 | 3 | use \Schema; |
| 4 | -use Illuminate\Http\Request; |
|
| 5 | 4 | use Taskforcedev\LaravelForum\Models\Forum; |
| 6 | 5 | use Taskforcedev\LaravelForum\Models\ForumPost; |
| 7 | 6 | use Taskforcedev\LaravelForum\Models\ForumReply; |
@@ -29,28 +29,28 @@ |
||
| 29 | 29 | |
| 30 | 30 | Route::group(['namespace' => 'Taskforcedev\LaravelForum\Http\Controllers', 'middleware' => 'api'], function() { |
| 31 | 31 | |
| 32 | - Route::group(['prefix' => 'api'], function() { |
|
| 33 | - /* Forum Category */ |
|
| 34 | - Route::post('forum_category', [ 'as' => 'laravel-forum.api.store.category', 'uses' => 'ApiController@forumCategoryStore' ]); |
|
| 35 | - Route::delete('forum_category', [ 'as' => 'laravel-forum.api.delete.forum.category', 'uses' => 'ApiController@forumCategoryDelete' ]); |
|
| 36 | - |
|
| 37 | - /* Forum */ |
|
| 38 | - Route::post('forum', [ 'as' => 'laravel-forum.api.store.forum', 'uses' => 'ApiController@forumStore' ]); |
|
| 39 | - Route::delete('forum', [ 'as' => 'laravel-forum.api.delete.forum', 'uses' => 'ApiController@forumDelete' ]); |
|
| 40 | - |
|
| 41 | - /* Forum Post */ |
|
| 42 | - Route::post('forum_post', [ 'as' => 'laravel-forum.api.store.forum.post', 'uses' => 'ApiController@forumPostStore' ]); |
|
| 43 | - Route::delete('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.api.delete.forum.post', 'uses' => 'ApiController@postDelete' ]); |
|
| 44 | - /* Forum Post: Reply */ |
|
| 45 | - Route::post('forum_reply', [ 'as' => 'laravel-forum.api.store.forum.reply', 'uses' => 'ApiController@forumReplyStore' ]); |
|
| 46 | - |
|
| 47 | - /* Lock Forum Post */ |
|
| 48 | - Route::post('post/unlock/{id}', [ 'as' => 'laravel-forum.api.post.unlock', 'uses' => 'ApiController@unlockPost' ]); |
|
| 49 | - Route::post('post/lock/{id}', [ 'as' => 'laravel-forum.api.post.lock', 'uses' => 'ApiController@lockPost' ]); |
|
| 50 | - |
|
| 51 | - /* Sticky Forum Post */ |
|
| 52 | - Route::post('post/sticky/{id}', [ 'as' => 'laravel-forum.api.post.sticky', 'uses' => 'ApiController@stickyPost' ]); |
|
| 53 | - Route::post('post/unsticky/{id}', [ 'as' => 'laravel-forum.api.post.unsticky', 'uses' => 'ApiController@unstickyPost' ]); |
|
| 54 | - }); |
|
| 32 | + Route::group(['prefix' => 'api'], function() { |
|
| 33 | + /* Forum Category */ |
|
| 34 | + Route::post('forum_category', [ 'as' => 'laravel-forum.api.store.category', 'uses' => 'ApiController@forumCategoryStore' ]); |
|
| 35 | + Route::delete('forum_category', [ 'as' => 'laravel-forum.api.delete.forum.category', 'uses' => 'ApiController@forumCategoryDelete' ]); |
|
| 36 | + |
|
| 37 | + /* Forum */ |
|
| 38 | + Route::post('forum', [ 'as' => 'laravel-forum.api.store.forum', 'uses' => 'ApiController@forumStore' ]); |
|
| 39 | + Route::delete('forum', [ 'as' => 'laravel-forum.api.delete.forum', 'uses' => 'ApiController@forumDelete' ]); |
|
| 40 | + |
|
| 41 | + /* Forum Post */ |
|
| 42 | + Route::post('forum_post', [ 'as' => 'laravel-forum.api.store.forum.post', 'uses' => 'ApiController@forumPostStore' ]); |
|
| 43 | + Route::delete('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.api.delete.forum.post', 'uses' => 'ApiController@postDelete' ]); |
|
| 44 | + /* Forum Post: Reply */ |
|
| 45 | + Route::post('forum_reply', [ 'as' => 'laravel-forum.api.store.forum.reply', 'uses' => 'ApiController@forumReplyStore' ]); |
|
| 46 | + |
|
| 47 | + /* Lock Forum Post */ |
|
| 48 | + Route::post('post/unlock/{id}', [ 'as' => 'laravel-forum.api.post.unlock', 'uses' => 'ApiController@unlockPost' ]); |
|
| 49 | + Route::post('post/lock/{id}', [ 'as' => 'laravel-forum.api.post.lock', 'uses' => 'ApiController@lockPost' ]); |
|
| 50 | + |
|
| 51 | + /* Sticky Forum Post */ |
|
| 52 | + Route::post('post/sticky/{id}', [ 'as' => 'laravel-forum.api.post.sticky', 'uses' => 'ApiController@stickyPost' ]); |
|
| 53 | + Route::post('post/unsticky/{id}', [ 'as' => 'laravel-forum.api.post.unsticky', 'uses' => 'ApiController@unstickyPost' ]); |
|
| 54 | + }); |
|
| 55 | 55 | |
| 56 | 56 | }); |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -Route::group(['namespace' => 'Taskforcedev\LaravelForum\Http\Controllers', 'middleware' => 'web'], function() { |
|
| 3 | +Route::group([ 'namespace' => 'Taskforcedev\LaravelForum\Http\Controllers', 'middleware' => 'web' ], function() { |
|
| 4 | 4 | // Public Routes |
| 5 | - Route::get('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.view.post', 'uses' => 'ForumController@viewPost' ]); |
|
| 5 | + Route::get('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.view.post', 'uses' => 'ForumController@viewPost' ]); |
|
| 6 | 6 | |
| 7 | - Route::get('forum/{id}/post', [ 'as' => 'laravel-forum.write.post', 'uses' => 'ForumController@createPost' ]); |
|
| 8 | - Route::get('forum/{id}', [ 'as' => 'laravel-forum.view', 'uses' => 'ForumController@view' ]); |
|
| 9 | - Route::get('forum', [ 'as' => 'laravel-forum.index', 'uses' => 'ForumController@index' ]); |
|
| 7 | + Route::get('forum/{id}/post', [ 'as' => 'laravel-forum.write.post', 'uses' => 'ForumController@createPost' ]); |
|
| 8 | + Route::get('forum/{id}', [ 'as' => 'laravel-forum.view', 'uses' => 'ForumController@view' ]); |
|
| 9 | + Route::get('forum', [ 'as' => 'laravel-forum.index', 'uses' => 'ForumController@index' ]); |
|
| 10 | 10 | |
| 11 | 11 | // Admin Routes. |
| 12 | - Route::group(['prefix' => 'admin'], function() { |
|
| 13 | - Route::get('forums', [ 'as' => 'laravel-forum.admin.index', 'uses' => 'AdminController@index' ]); |
|
| 12 | + Route::group([ 'prefix' => 'admin' ], function() { |
|
| 13 | + Route::get('forums', [ 'as' => 'laravel-forum.admin.index', 'uses' => 'AdminController@index' ]); |
|
| 14 | 14 | |
| 15 | - Route::group(['prefix' => 'forums'], function() { |
|
| 15 | + Route::group([ 'prefix' => 'forums' ], function() { |
|
| 16 | 16 | /* Forums */ |
| 17 | - Route::get('forums', [ 'as' => 'laravel-forum.admin.forums', 'uses' => 'AdminController@forums' ]); |
|
| 18 | - Route::get('forums/create', ['as' => 'laravel-forum.admin.forum.create', 'uses' => 'AdminController@forumForm' ]); |
|
| 17 | + Route::get('forums', [ 'as' => 'laravel-forum.admin.forums', 'uses' => 'AdminController@forums' ]); |
|
| 18 | + Route::get('forums/create', [ 'as' => 'laravel-forum.admin.forum.create', 'uses' => 'AdminController@forumForm' ]); |
|
| 19 | 19 | |
| 20 | 20 | /* Categories */ |
| 21 | - Route::get('categories/create', ['as' => 'laravel-forum.admin.category.create', 'uses' => 'AdminController@categoryForm' ]); |
|
| 22 | - Route::get('categories', ['as' => 'laravel-forum.admin.categories', 'uses' => 'AdminController@categories']); |
|
| 21 | + Route::get('categories/create', [ 'as' => 'laravel-forum.admin.category.create', 'uses' => 'AdminController@categoryForm' ]); |
|
| 22 | + Route::get('categories', [ 'as' => 'laravel-forum.admin.categories', 'uses' => 'AdminController@categories' ]); |
|
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | 25 | |
@@ -27,29 +27,29 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | -Route::group(['namespace' => 'Taskforcedev\LaravelForum\Http\Controllers', 'middleware' => ['web', 'api']], function() { |
|
| 30 | +Route::group([ 'namespace' => 'Taskforcedev\LaravelForum\Http\Controllers', 'middleware' => [ 'web', 'api' ] ], function() { |
|
| 31 | 31 | |
| 32 | - Route::group(['prefix' => 'api'], function() { |
|
| 32 | + Route::group([ 'prefix' => 'api' ], function() { |
|
| 33 | 33 | /* Forum Category */ |
| 34 | - Route::post('forum_category', [ 'as' => 'laravel-forum.api.store.category', 'uses' => 'ApiController@forumCategoryStore' ]); |
|
| 34 | + Route::post('forum_category', [ 'as' => 'laravel-forum.api.store.category', 'uses' => 'ApiController@forumCategoryStore' ]); |
|
| 35 | 35 | Route::delete('forum_category', [ 'as' => 'laravel-forum.api.delete.forum.category', 'uses' => 'ApiController@forumCategoryDelete' ]); |
| 36 | 36 | |
| 37 | 37 | /* Forum */ |
| 38 | - Route::post('forum', [ 'as' => 'laravel-forum.api.store.forum', 'uses' => 'ApiController@forumStore' ]); |
|
| 38 | + Route::post('forum', [ 'as' => 'laravel-forum.api.store.forum', 'uses' => 'ApiController@forumStore' ]); |
|
| 39 | 39 | Route::delete('forum', [ 'as' => 'laravel-forum.api.delete.forum', 'uses' => 'ApiController@forumDelete' ]); |
| 40 | 40 | |
| 41 | 41 | /* Forum Post */ |
| 42 | - Route::post('forum_post', [ 'as' => 'laravel-forum.api.store.forum.post', 'uses' => 'ApiController@forumPostStore' ]); |
|
| 43 | - Route::delete('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.api.delete.forum.post', 'uses' => 'ApiController@postDelete' ]); |
|
| 42 | + Route::post('forum_post', [ 'as' => 'laravel-forum.api.store.forum.post', 'uses' => 'ApiController@forumPostStore' ]); |
|
| 43 | + Route::delete('forum/{id}/post/{pid}', [ 'as' => 'laravel-forum.api.delete.forum.post', 'uses' => 'ApiController@postDelete' ]); |
|
| 44 | 44 | /* Forum Post: Reply */ |
| 45 | 45 | Route::post('forum_reply', [ 'as' => 'laravel-forum.api.store.forum.reply', 'uses' => 'ApiController@forumReplyStore' ]); |
| 46 | 46 | |
| 47 | 47 | /* Lock Forum Post */ |
| 48 | 48 | Route::post('post/unlock/{id}', [ 'as' => 'laravel-forum.api.post.unlock', 'uses' => 'ApiController@unlockPost' ]); |
| 49 | - Route::post('post/lock/{id}', [ 'as' => 'laravel-forum.api.post.lock', 'uses' => 'ApiController@lockPost' ]); |
|
| 49 | + Route::post('post/lock/{id}', [ 'as' => 'laravel-forum.api.post.lock', 'uses' => 'ApiController@lockPost' ]); |
|
| 50 | 50 | |
| 51 | 51 | /* Sticky Forum Post */ |
| 52 | - Route::post('post/sticky/{id}', [ 'as' => 'laravel-forum.api.post.sticky', 'uses' => 'ApiController@stickyPost' ]); |
|
| 52 | + Route::post('post/sticky/{id}', [ 'as' => 'laravel-forum.api.post.sticky', 'uses' => 'ApiController@stickyPost' ]); |
|
| 53 | 53 | Route::post('post/unsticky/{id}', [ 'as' => 'laravel-forum.api.post.unsticky', 'uses' => 'ApiController@unstickyPost' ]); |
| 54 | 54 | }); |
| 55 | 55 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Eloquent Relation. |
| 25 | - * @return mixed |
|
| 25 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
| 26 | 26 | */ |
| 27 | 27 | public function author() |
| 28 | 28 | { |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | protected $table = 'forum_post_replies'; |
| 19 | 19 | |
| 20 | - protected $hidden = []; |
|
| 21 | - protected $fillable = ['body', 'post_id', 'author_id']; |
|
| 20 | + protected $hidden = [ ]; |
|
| 21 | + protected $fillable = [ 'body', 'post_id', 'author_id' ]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Eloquent Relation. |
@@ -59,6 +59,6 @@ discard block |
||
| 59 | 59 | public static function getReplyCount() |
| 60 | 60 | { |
| 61 | 61 | $results = DB::select('select COUNT(*) as count from forum_post_replies'); |
| 62 | - return $results[0]->count; |
|
| 62 | + return $results[ 0 ]->count; |
|
| 63 | 63 | } |
| 64 | 64 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | if (!Schema::hasColumn('forum_posts', 'sticky') && !Schema::hasColumn('forum_posts', 'locked')) { |
| 11 | - Schema::table('forum_posts', function ($table) { |
|
| 11 | + Schema::table('forum_posts', function($table) { |
|
| 12 | 12 | $table->boolean('sticky')->default(0); |
| 13 | 13 | $table->boolean('locked')->default(0); |
| 14 | 14 | }); |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function down() |
| 19 | 19 | { |
| 20 | - Schema::table('forum_posts', function ($table) { |
|
| 21 | - $table->dropColumn(['sticky', 'locked']); |
|
| 20 | + Schema::table('forum_posts', function($table) { |
|
| 21 | + $table->dropColumn([ 'sticky', 'locked' ]); |
|
| 22 | 22 | }); |
| 23 | 23 | } |
| 24 | 24 | } |