From e320bec8993ee506f7d5d7609b8b4f05f89c8d6b Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Wed, 15 Feb 2017 18:34:47 +0000 Subject: [PATCH] Refactor method names/views for Articles --- app/Http/Controllers/ArticlesController.php | 10 +++++----- .../{articles.blade.php => articles/index.blade.php} | 0 resources/views/{ => articles}/rss.blade.php | 0 .../{article.blade.php => articles/show.blade.php} | 0 routes/web.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) rename resources/views/{articles.blade.php => articles/index.blade.php} (100%) rename resources/views/{ => articles}/rss.blade.php (100%) rename resources/views/{article.blade.php => articles/show.blade.php} (100%) diff --git a/app/Http/Controllers/ArticlesController.php b/app/Http/Controllers/ArticlesController.php index be0d500c..b88656e8 100644 --- a/app/Http/Controllers/ArticlesController.php +++ b/app/Http/Controllers/ArticlesController.php @@ -12,14 +12,14 @@ class ArticlesController extends Controller * * @return \Illuminate\View\Factory view */ - public function showAllArticles($year = null, $month = null) + public function index($year = null, $month = null) { $articles = Article::where('published', '1') ->date($year, $month) ->orderBy('updated_at', 'desc') ->simplePaginate(5); - return view('articles', compact('articles')); + return view('articles.index', compact('articles')); } /** @@ -27,14 +27,14 @@ class ArticlesController extends Controller * * @return \Illuminate\View\Factory view */ - public function singleArticle($year, $month, $slug) + public function show($year, $month, $slug) { $article = Article::where('titleurl', $slug)->first(); if ($article->updated_at->year != $year || $article->updated_at->month != $month) { throw new \Exception; } - return view('article', compact('article')); + return view('articles.show', compact('article')); } /** @@ -63,7 +63,7 @@ class ArticlesController extends Controller $buildDate = $articles->first()->updated_at->toRssString(); return response() - ->view('rss', compact('articles', 'buildDate'), 200) + ->view('articles.rss', compact('articles', 'buildDate'), 200) ->header('Content-Type', 'application/rss+xml'); } } diff --git a/resources/views/articles.blade.php b/resources/views/articles/index.blade.php similarity index 100% rename from resources/views/articles.blade.php rename to resources/views/articles/index.blade.php diff --git a/resources/views/rss.blade.php b/resources/views/articles/rss.blade.php similarity index 100% rename from resources/views/rss.blade.php rename to resources/views/articles/rss.blade.php diff --git a/resources/views/article.blade.php b/resources/views/articles/show.blade.php similarity index 100% rename from resources/views/article.blade.php rename to resources/views/articles/show.blade.php diff --git a/routes/web.php b/routes/web.php index 6c8a4c36..2121becd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -84,8 +84,8 @@ Route::group(['domain' => config('url.longurl')], function () { //Blog pages using ArticlesController Route::get('blog/s/{id}', 'ArticlesController@onlyIdInURL'); - Route::get('blog/{year?}/{month?}', 'ArticlesController@showAllArticles'); - Route::get('blog/{year}/{month}/{slug}', 'ArticlesController@singleArticle'); + Route::get('blog/{year?}/{month?}', 'ArticlesController@index'); + Route::get('blog/{year}/{month}/{slug}', 'ArticlesController@show'); //micropub new notes page //this needs to be first so `notes/new` doesn't match `notes/{id}`