@@ -20,8 +20,9 @@ |
||
| 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 | /** |
@@ -92,9 +92,10 @@ |
||
| 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 | {
|
@@ -86,16 +86,16 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -20,8 +20,9 @@ |
||
| 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 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -117,10 +117,11 @@ |
||
| 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 | } |
@@ -31,7 +31,7 @@ |
||
| 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. |
@@ -7,7 +7,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -41,31 +41,31 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -65,8 +65,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | }); |
@@ -63,7 +63,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -170,8 +170,9 @@ |
||
| 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'),
|
@@ -150,7 +150,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | {
|
@@ -1,15 +1,11 @@ |
||
| 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 |
@@ -65,7 +65,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -80,11 +80,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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'),
|
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * Post update form processing page. |
| 95 | 95 | * |
| 96 | 96 | * @param int $id |
| 97 | - * @return Redirect |
|
| 97 | + * @return \Illuminate\Http\RedirectResponse |
|
| 98 | 98 | */ |
| 99 | 99 | public function postEdit($id = null) |
| 100 | 100 | {
|
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | /** |
| 179 | 179 | * Post create form processing. |
| 180 | 180 | * |
| 181 | - * @return Redirect |
|
| 181 | + * @return \Illuminate\Http\RedirectResponse |
|
| 182 | 182 | */ |
| 183 | 183 | public function postCreate() |
| 184 | 184 | {
|
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * Delete the given post. |
| 253 | 253 | * |
| 254 | 254 | * @param int $id |
| 255 | - * @return Redirect |
|
| 255 | + * @return \Illuminate\Http\RedirectResponse |
|
| 256 | 256 | */ |
| 257 | 257 | public function getDelete($id = null) |
| 258 | 258 | {
|
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * Restore a deleted post. |
| 299 | 299 | * |
| 300 | 300 | * @param int $id |
| 301 | - * @return Redirect |
|
| 301 | + * @return \Illuminate\Http\RedirectResponse |
|
| 302 | 302 | */ |
| 303 | 303 | public function getRestore($id = null) |
| 304 | 304 | {
|
@@ -1,15 +1,12 @@ |
||
| 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 Sentinel; |
|
| 6 | +use Validator; |
|
| 7 | +use Input; |
|
| 8 | +use Base; |
|
| 9 | +use Redirect; |
|
| 13 | 10 | use Lang; |
| 14 | 11 | |
| 15 | 12 | class PostController extends Controller |