Completed
Push — master ( 9d9a88...6b3a24 )
by Joao
02:31
created
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/BlogController.php 1 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/Controllers/CategoryController.php 2 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.
src/Controllers/PostController.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $post = Blog::getPostsRepository()->find($id);
66 66
 
67 67
         // Get the post information
68
-        if($post == null)
68
+        if ($post == null)
69 69
         {
70 70
             // Prepare the error message
71 71
             $error = Lang::get('blog.posts.not_found');
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $cats[$cat->id] = $cat->name;
85 85
 
86 86
         foreach ($authors as $author)
87
-            $users[$author->id] = $author->first_name . ' ' . $author->last_name;
87
+            $users[$author->id] = $author->first_name.' '.$author->last_name;
88 88
 
89 89
         // Show the page
90 90
         return View('admin.posts.edit', compact('post', 'cats', 'users'));
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         // Was the post updated?
138 138
         if ($post->save())
139 139
         {
140
-            Base::Log('Post (' . $post->id . ') was edited.');
140
+            Base::Log('Post ('.$post->id.') was edited.');
141 141
 
142 142
             // Prepare the success message
143 143
             $success = Lang::get('blog.posts.changed');
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $cats[$cat->id] = $cat->name;
170 170
 
171 171
         foreach ($authors as $author)
172
-            $users[$author->id] = $author->first_name . ' ' . $author->last_name;
172
+            $users[$author->id] = $author->first_name.' '.$author->last_name;
173 173
 
174 174
         // Show the page
175 175
         return View('admin.posts.create', compact('cats', 'users'));
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
         $post->save();
217 217
 
218
-        Base::Log('A new post (' . $post->id . ') was created.');
218
+        Base::Log('A new post ('.$post->id.') was created.');
219 219
 
220 220
         // Redirect to the home page with success menu
221 221
         return Redirect::route("posts")->with('success', Lang::get('blog.posts.created'));
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
             return Redirect::route('posts')->with('error', $error);
269 269
         }
270 270
 
271
-        Base::Log('Post (' . $post->id . ') was deleted.');
271
+        Base::Log('Post ('.$post->id.') was deleted.');
272 272
 
273 273
         // Delete the post
274 274
         $post->delete();
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             return Redirect::route('post.deleted')->with('error', $error);
315 315
         }
316 316
 
317
-        Base::Log('Post (' . $post->id . ') was restored.');
317
+        Base::Log('Post ('.$post->id.') was restored.');
318 318
 
319 319
         // Restore the post
320 320
         $post->restore();
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -80,11 +80,13 @@  discard block
 block discarded – undo
80 80
         $categories = Blog::getCategoriesRepository()->all(['id', 'name']);
81 81
         $authors = Sentinel::createModel()->all(['id', 'first_name', 'last_name']);
82 82
 
83
-        foreach ($categories as $cat)
84
-            $cats[$cat->id] = $cat->name;
83
+        foreach ($categories as $cat) {
84
+                    $cats[$cat->id] = $cat->name;
85
+        }
85 86
 
86
-        foreach ($authors as $author)
87
-            $users[$author->id] = $author->first_name . ' ' . $author->last_name;
87
+        foreach ($authors as $author) {
88
+                    $users[$author->id] = $author->first_name . ' ' . $author->last_name;
89
+        }
88 90
 
89 91
         // Show the page
90 92
         return View('admin.posts.edit', compact('post', 'cats', 'users'));
@@ -165,11 +167,13 @@  discard block
 block discarded – undo
165 167
         $categories = Blog::getCategoriesRepository()->all(['id', 'name']);
166 168
         $authors = Sentinel::createModel()->all(['id', 'first_name', 'last_name']);
167 169
 
168
-        foreach ($categories as $cat)
169
-            $cats[$cat->id] = $cat->name;
170
+        foreach ($categories as $cat) {
171
+                    $cats[$cat->id] = $cat->name;
172
+        }
170 173
 
171
-        foreach ($authors as $author)
172
-            $users[$author->id] = $author->first_name . ' ' . $author->last_name;
174
+        foreach ($authors as $author) {
175
+                    $users[$author->id] = $author->first_name . ' ' . $author->last_name;
176
+        }
173 177
 
174 178
         // Show the page
175 179
         return View('admin.posts.create', compact('cats', 'users'));
@@ -198,8 +202,9 @@  discard block
 block discarded – undo
198 202
 
199 203
         $post = Blog::getPostsRepository()->findBySlug($slug);
200 204
 
201
-        if ($post != null)
202
-            return Redirect::route("posts")->with('error', Lang::get('blog.posts.already_exists'));
205
+        if ($post != null) {
206
+                    return Redirect::route("posts")->with('error', Lang::get('blog.posts.already_exists'));
207
+        }
203 208
 
204 209
         $post = Blog::getPostsRepository()->create([
205 210
             'title' => Input::get('title'),
Please login to merge, or discard this patch.