Completed
Push — master ( 6b3a24...b90a02 )
by Joao
10:27
created
src/Migrations/2016_01_15_123600_create_blog_tables.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     public function up()
14 14
     {
15 15
 
16
-        Schema::create('BlogCategory', function (Blueprint $table) {
16
+        Schema::create('BlogCategory', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->string('name', 100);
19 19
             $table->string('slug', 100);
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
             $table->creation();
25 25
         });
26 26
 
27
-        Schema::table('BlogCategory', function (Blueprint $table) {
27
+        Schema::table('BlogCategory', function(Blueprint $table) {
28 28
             $table->creationRelation();
29 29
         });
30 30
 
31
-        Schema::create('BlogPost', function (Blueprint $table) {
31
+        Schema::create('BlogPost', function(Blueprint $table) {
32 32
             $table->increments('id');
33 33
             $table->string('title', 100);
34 34
             $table->string('slug', 100);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             $table->foreign('author')->references('id')->on('User');
49 49
         });
50 50
 
51
-        Schema::table('BlogPost', function (Blueprint $table) {
51
+        Schema::table('BlogPost', function(Blueprint $table) {
52 52
             $table->creationRelation();
53 53
         });
54 54
 
Please login to merge, or discard this patch.
src/Repositories/BlogCategoryRepository.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($model = null)
22 22
     {
23
-        if (isset($model))
24
-            $this->model = $model;
23
+        if (isset($model)) {
24
+                    $this->model = $model;
25
+        }
25 26
     }
26 27
 
27 28
     /**
Please login to merge, or discard this patch.
src/Controllers/BlogController.php 2 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,9 +92,10 @@
 block discarded – undo
92 92
 
93 93
     public function applySearch($repo, $terms, $fields)
94 94
     {
95
-        foreach($terms as $term)
96
-            foreach($fields as $field)
97
-                $repo = $repo->orWhere($field, 'LIKE', '%' . $term . '%');
95
+        foreach($terms as $term) {
96
+                    foreach($fields as $field)
97
+                $repo = $repo->orWhere($field, 'LIKE', '%' . $term . '%');
98
+        }
98 99
 
99 100
         foreach($repo as $data)
100 101
         {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
         $categories = $this->applySearch(Blog::getCategoriesRepository(), $terms, ['name', 'description'])->select('name as a', DB::raw('\'Category\' AS type'))->distinct()->get()->toArray();
87 87
 
88 88
         // Returning the results
89
-        return response()->json( [ 'data' => array_merge($users, $categories, $posts) ] );
89
+        return response()->json(['data' => array_merge($users, $categories, $posts)]);
90 90
     }
91 91
 
92 92
     public function applySearch($repo, $terms, $fields)
93 93
     {
94
-        foreach($terms as $term)
95
-            foreach($fields as $field)
96
-                $repo = $repo->orWhere($field, 'LIKE', '%' . $term . '%');
94
+        foreach ($terms as $term)
95
+            foreach ($fields as $field)
96
+                $repo = $repo->orWhere($field, 'LIKE', '%'.$term.'%');
97 97
 
98
-        foreach($repo as $data)
98
+        foreach ($repo as $data)
99 99
         {
100 100
             dd($repo);
101 101
         }
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
         // Was the post updated?
148 148
         if ($post->comments()->save($c))
149 149
         {
150
-            Base::Log('Comment added to (' . $post->id . ').');
150
+            Base::Log('Comment added to ('.$post->id.').');
151 151
 
152 152
             // Prepare the success message
153 153
             $success = Lang::get('blog.comment.created');
154 154
 
155 155
             // Redirect to the user page
156
-            return Redirect('blog/' . $post->id)->with('success', $success);
156
+            return Redirect('blog/'.$post->id)->with('success', $success);
157 157
         }
158 158
 
159 159
         $error = Lang::get('blog.comment.error');
160 160
 
161 161
         // Redirect to the post page
162
-        return Redirect('blog/' . $post->id)->withInput()->with('error', $error);
162
+        return Redirect('blog/'.$post->id)->withInput()->with('error', $error);
163 163
     }
164 164
     
165 165
 }
Please login to merge, or discard this patch.
src/Repositories/BlogPostRepository.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($model = null)
22 22
     {
23
-        if (isset($model))
24
-            $this->model = $model;
23
+        if (isset($model)) {
24
+                    $this->model = $model;
25
+        }
25 26
     }
26 27
 
27 28
     /**
Please login to merge, or discard this patch.
src/Models/BlogPost.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     protected static $categoryModel = 'jlourenco\blog\Models\BlogCategory';
42 42
 
43
-    protected $dates = [ 'created_at', 'deleted_at'];
43
+    protected $dates = ['created_at', 'deleted_at'];
44 44
 
45 45
     /**
46 46
      * {@inheritDoc}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         if ($value > 0)
121 121
             if ($user = Sentinel::findUserById($value))
122 122
                 if ($user != null)
123
-                    return $user->first_name . ' ' . $user->last_name;
123
+                    return $user->first_name.' '.$user->last_name;
124 124
 
125 125
         return $value;
126 126
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,10 +117,11 @@
 block discarded – undo
117 117
      */
118 118
     public function getCreatedByAttribute($value)
119 119
     {
120
-        if ($value > 0)
121
-            if ($user = Sentinel::findUserById($value))
120
+        if ($value > 0) {
121
+                    if ($user = Sentinel::findUserById($value))
122 122
                 if ($user != null)
123
-                    return $user->first_name . ' ' . $user->last_name;
123
+                    return $user->first_name . ' ' . $user->last_name;
124
+        }
124 125
 
125 126
         return $value;
126 127
     }
Please login to merge, or discard this patch.
src/Models/BlogCategory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         'slug'
32 32
     ];
33 33
 
34
-    protected $dates = [ 'created_at', 'deleted_at'];
34
+    protected $dates = ['created_at', 'deleted_at'];
35 35
 
36 36
     /**
37 37
      * The Blog post model name.
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * All the "restricted area" routes
8 8
  * are defined here.
9 9
  */
10
-Route::group(array('prefix' => '/', 'middleware' => 'webPublic'), function ()
10
+Route::group(array('prefix' => '/', 'middleware' => 'webPublic'), function()
11 11
 {
12 12
 
13 13
     # Blog pages
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
  * All the "restricted area" routes
26 26
  * are defined here.
27 27
  */
28
-Route::group(array('prefix' => '/admin', 'middleware' => ['webAdmin', 'auth']), function ()
28
+Route::group(array('prefix' => '/admin', 'middleware' => ['webAdmin', 'auth']), function()
29 29
 {
30 30
 
31 31
     # Blog Management
32
-    Route::group(array('prefix' => 'categories'), function () {
32
+    Route::group(array('prefix' => 'categories'), function() {
33 33
         Route::get('/list', array('as' => 'categories', 'uses' => 'jlourenco\blog\Controllers\CategoryController@index'));
34 34
         Route::get('/create', array('as' => 'create.category', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getCreate'));
35 35
         Route::post('/create', 'jlourenco\blog\Controllers\CategoryController@postCreate');
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
         Route::get('{blogId}/delete', array('as' => 'delete/category', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getDelete'));
39 39
         Route::get('{blogId}/confirm-delete', array('as' => 'confirm-delete/category', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getModalDelete'));
40 40
         Route::get('{blogId}/restore', array('as' => 'restore/category', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getRestore'));
41
-        Route::get('deleted',array('as' => 'categories.deleted', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getDeletedCategories'));
41
+        Route::get('deleted', array('as' => 'categories.deleted', 'uses' => 'jlourenco\blog\Controllers\CategoryController@getDeletedCategories'));
42 42
         Route::get('{blogId}', array('as' => 'category.show', 'uses' => 'jlourenco\blog\Controllers\CategoryController@show'));
43 43
     });
44 44
 
45
-    Route::group(array('prefix' => 'posts'), function () {
45
+    Route::group(array('prefix' => 'posts'), function() {
46 46
         Route::get('/list', array('as' => 'posts', 'uses' => 'jlourenco\blog\Controllers\PostController@index'));
47 47
         Route::get('/create', array('as' => 'create.post', 'uses' => 'jlourenco\blog\Controllers\PostController@getCreate'));
48 48
         Route::post('/create', 'jlourenco\blog\Controllers\PostController@postCreate');
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         Route::get('{blogId}/delete', array('as' => 'delete/post', 'uses' => 'jlourenco\blog\Controllers\PostController@getDelete'));
52 52
         Route::get('{blogId}/confirm-delete', array('as' => 'confirm-delete/post', 'uses' => 'jlourenco\blog\Controllers\PostController@getModalDelete'));
53 53
         Route::get('{blogId}/restore', array('as' => 'restore/post', 'uses' => 'jlourenco\blog\Controllers\PostController@getRestore'));
54
-        Route::get('deleted',array('as' => 'posts.deleted', 'uses' => 'jlourenco\blog\Controllers\PostController@getDeletedCategories'));
54
+        Route::get('deleted', array('as' => 'posts.deleted', 'uses' => 'jlourenco\blog\Controllers\PostController@getDeletedCategories'));
55 55
         Route::get('{blogId}', array('as' => 'post.show', 'uses' => 'jlourenco\blog\Controllers\PostController@show'));
56 56
     });
57 57
 
Please login to merge, or discard this patch.
src/blogServiceProvider.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,31 +41,31 @@  discard block
 block discarded – undo
41 41
         // Publish our views
42 42
         $this->loadViewsFrom(base_path("resources/views"), 'base');
43 43
         $this->publishes([
44
-            __DIR__ .  '/views' => base_path("resources/views")
44
+            __DIR__.'/views' => base_path("resources/views")
45 45
         ]);
46 46
 
47 47
         // Publish our lang
48 48
         $this->publishes([
49
-            __DIR__ .  '/lang' => base_path("resources/lang")
49
+            __DIR__.'/lang' => base_path("resources/lang")
50 50
         ], 'migrations');
51 51
 
52 52
         // Publish our migrations
53 53
         $this->publishes([
54
-            __DIR__ .  '/migrations' => base_path("database/migrations")
54
+            __DIR__.'/migrations' => base_path("database/migrations")
55 55
         ], 'migrations');
56 56
 
57 57
         // Publish a config file
58 58
         $this->publishes([
59
-            __DIR__ . '/config' => base_path('/config')
59
+            __DIR__.'/config' => base_path('/config')
60 60
         ], 'config');
61 61
 
62 62
         // Publish our routes
63 63
         $this->publishes([
64
-            __DIR__ .  '/routes.php' => base_path("app/Http/blog_routes.php")
64
+            __DIR__.'/routes.php' => base_path("app/Http/blog_routes.php")
65 65
         ], 'routes');
66 66
 
67 67
         // Include the routes file
68
-        if(file_exists(base_path("app/Http/blog_routes.php")))
68
+        if (file_exists(base_path("app/Http/blog_routes.php")))
69 69
             include base_path("app/Http/blog_routes.php");
70 70
     }
71 71
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     protected function registerBlogPost()
78 78
     {
79
-        $this->app->singleton('jlourenco.blog.post', function ($app) {
79
+        $this->app->singleton('jlourenco.blog.post', function($app) {
80 80
             $baseConfig = $app['config']->get('jlourenco.base');
81 81
             $config = $app['config']->get('jlourenco.blog');
82 82
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     protected function registerBlogCategory()
103 103
     {
104
-        $this->app->singleton('jlourenco.blog.category', function ($app) {
104
+        $this->app->singleton('jlourenco.blog.category', function($app) {
105 105
             $config = $app['config']->get('jlourenco.blog');
106 106
 
107 107
             $model = array_get($config, 'models.BlogCategory');
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     protected function registerBlog()
123 123
     {
124
-        $this->app->singleton('blog', function ($app) {
124
+        $this->app->singleton('blog', function($app) {
125 125
             $blog = new Blog($app['jlourenco.blog.post'], $app['jlourenco.blog.category']);
126 126
 
127 127
             return $blog;
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,8 +65,9 @@  discard block
 block discarded – undo
65 65
         ], 'routes');
66 66
 
67 67
         // Include the routes file
68
-        if(file_exists(base_path("app/Http/blog_routes.php")))
69
-            include base_path("app/Http/blog_routes.php");
68
+        if(file_exists(base_path("app/Http/blog_routes.php"))) {
69
+                    include base_path("app/Http/blog_routes.php");
70
+        }
70 71
     }
71 72
 
72 73
     /**
@@ -84,11 +85,13 @@  discard block
 block discarded – undo
84 85
             $users = array_get($baseConfig, 'models.User');
85 86
             $categories = array_get($config, 'models.BlogCategory');
86 87
 
87
-            if (class_exists($model) && method_exists($model, 'setUsersModel'))
88
-                forward_static_call_array([$model, 'setUsersModel'], [$users]);
88
+            if (class_exists($model) && method_exists($model, 'setUsersModel')) {
89
+                            forward_static_call_array([$model, 'setUsersModel'], [$users]);
90
+            }
89 91
 
90
-            if (class_exists($model) && method_exists($model, 'setCategoriesModel'))
91
-                forward_static_call_array([$model, 'setCategoriesModel'], [$categories]);
92
+            if (class_exists($model) && method_exists($model, 'setCategoriesModel')) {
93
+                            forward_static_call_array([$model, 'setCategoriesModel'], [$categories]);
94
+            }
92 95
 
93 96
             return new BlogPostRepository($model);
94 97
         });
@@ -107,8 +110,9 @@  discard block
 block discarded – undo
107 110
             $model = array_get($config, 'models.BlogCategory');
108 111
             $posts = array_get($config, 'models.BlogPost');
109 112
 
110
-            if (class_exists($model) && method_exists($model, 'setPostsModel'))
111
-                forward_static_call_array([$model, 'setPostsModel'], [$posts]);
113
+            if (class_exists($model) && method_exists($model, 'setPostsModel')) {
114
+                            forward_static_call_array([$model, 'setPostsModel'], [$posts]);
115
+            }
112 116
 
113 117
             return new BlogCategoryRepository($model);
114 118
         });
Please login to merge, or discard this patch.
src/Controllers/CategoryController.php 4 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $cat = Blog::getCategoriesRepository()->find($id);
64 64
 
65 65
         // Get the category information
66
-        if($cat == null)
66
+        if ($cat == null)
67 67
         {
68 68
             // Prepare the error message
69 69
             $error = Lang::get('blog.category.not_found');
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         // Was the category updated?
122 122
         if ($cat->save())
123 123
         {
124
-            Base::Log('Category (' . $cat->name . ') was edited.');
124
+            Base::Log('Category ('.$cat->name.') was edited.');
125 125
 
126 126
             // Prepare the success message
127 127
             $success = Lang::get('blog.category.changed');
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
         $cat->save();
183 183
 
184
-        Base::Log('A new category (' . $cat->name . ') was created.');
184
+        Base::Log('A new category ('.$cat->name.') was created.');
185 185
 
186 186
         // Redirect to the home page with success menu
187 187
         return Redirect::route("categories")->with('success', Lang::get('blog.category.created'));
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             return Redirect::route('categories')->with('error', $error);
235 235
         }
236 236
 
237
-        Base::Log('Category (' . $cat->name . ') was deleted.');
237
+        Base::Log('Category ('.$cat->name.') was deleted.');
238 238
 
239 239
         // Delete the category
240 240
         $cat->delete();
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             return Redirect::route('category.deleted')->with('error', $error);
281 281
         }
282 282
 
283
-        Base::Log('Category (' . $cat->name . ') was restored.');
283
+        Base::Log('Category ('.$cat->name.') was restored.');
284 284
 
285 285
         // Restore the category
286 286
         $cat->restore();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,8 +170,9 @@
 block discarded – undo
170 170
 
171 171
         $cat = Blog::getCategoriesRepository()->findBySlug($slug);
172 172
 
173
-        if ($cat != null)
174
-            return Redirect::route("categories")->with('error', Lang::get('blog.category.already_exists'));
173
+        if ($cat != null) {
174
+                    return Redirect::route("categories")->with('error', Lang::get('blog.category.already_exists'));
175
+        }
175 176
 
176 177
         $cat = Blog::getCategoriesRepository()->create([
177 178
             'name' => Input::get('name'),
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     /**
151 151
      * Category create form processing.
152 152
      *
153
-     * @return Redirect
153
+     * @return \Illuminate\Http\RedirectResponse
154 154
      */
155 155
     public function postCreate()
156 156
     {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * Delete the given category.
219 219
      *
220 220
      * @param  int      $id
221
-     * @return Redirect
221
+     * @return \Illuminate\Http\RedirectResponse
222 222
      */
223 223
     public function getDelete($id = null)
224 224
     {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * Restore a deleted category.
265 265
      *
266 266
      * @param  int      $id
267
-     * @return Redirect
267
+     * @return \Illuminate\Http\RedirectResponse
268 268
      */
269 269
     public function getRestore($id = null)
270 270
     {
Please login to merge, or discard this patch.
Unused Use Statements   +6 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,11 @@
 block discarded – undo
1 1
 <?php namespace jlourenco\blog\Controllers;
2 2
 
3
-use Illuminate\Http\Request;
4
-use App\Http\Requests;
5
-use App\Http\Controllers\Controller;
6
-use Blog;
7
-use Sentinel;
8
-use Searchy;
9
-use Validator;
10
-use Input;
11
-use Base;
12
-use Redirect;
3
+use App\Http\Controllers\Controller;
4
+use Blog;
5
+use Validator;
6
+use Input;
7
+use Base;
8
+use Redirect;
13 9
 use Lang;
14 10
 
15 11
 class CategoryController extends Controller
Please login to merge, or discard this patch.