From f764d2a15847722a64e1e618bf7df61096762104 Mon Sep 17 00:00:00 2001 From: Antoine Augusti Date: Sun, 22 Nov 2015 11:30:40 +0100 Subject: [PATCH 1/2] Use dedicated class for available routes --- .../AdminPanel/AdminPanelServiceProvider.php | 15 +++++++++------ app/TeenQuotes/AdminPanel/Helpers/Moderation.php | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php b/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php index d6353202..d1c45aea 100644 --- a/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php +++ b/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php @@ -12,6 +12,7 @@ namespace TeenQuotes\AdminPanel; use Illuminate\Support\ServiceProvider; +use TeenQuotes\AdminPanel\Helpers\Moderation; class AdminPanelServiceProvider extends ServiceProvider { @@ -33,13 +34,15 @@ public function register() private function registerRoutes() { - $this->app['router']->pattern('decision', 'approve|unapprove|alert'); + $this->app['router']->pattern('decision', Moderation::presentAvailableTypes()); - $this->app['router']->group($this->getRouteGroupParams(), function () { - $this->app['router']->get('/', ['uses' => $this->getController().'@index', 'as' => 'admin.quotes.index']); - $this->app['router']->get('edit/{quote_id}', ['uses' => $this->getController().'@edit', 'as' => 'admin.quotes.edit']); - $this->app['router']->put('update/{quote_id}', ['uses' => $this->getController().'@update', 'as' => 'admin.quotes.update']); - $this->app['router']->post('moderate/{quote_id}/{decision}', ['uses' => $this->getController().'@postModerate', 'as' => 'admin.quotes.moderate']); + $controller = $this->getController(); + + $this->app['router']->group($this->getRouteGroupParams(), function () use($controller) { + $this->app['router']->get('/', ['uses' => $controller.'@index', 'as' => 'admin.quotes.index']); + $this->app['router']->get('edit/{quote_id}', ['uses' => $controller.'@edit', 'as' => 'admin.quotes.edit']); + $this->app['router']->put('update/{quote_id}', ['uses' => $controller.'@update', 'as' => 'admin.quotes.update']); + $this->app['router']->post('moderate/{quote_id}/{decision}', ['uses' => $controller.'@postModerate', 'as' => 'admin.quotes.moderate']); }); } diff --git a/app/TeenQuotes/AdminPanel/Helpers/Moderation.php b/app/TeenQuotes/AdminPanel/Helpers/Moderation.php index a78bd4e6..538ebf9e 100644 --- a/app/TeenQuotes/AdminPanel/Helpers/Moderation.php +++ b/app/TeenQuotes/AdminPanel/Helpers/Moderation.php @@ -69,7 +69,7 @@ public static function getAvailableTypes() * * @return string */ - private function presentAvailableTypes() + public static function presentAvailableTypes() { return implode('|', self::getAvailableTypes()); } From 2ab853720b064de19b7ab729d83507b8d292390e Mon Sep 17 00:00:00 2001 From: Antoine Augusti Date: Sun, 22 Nov 2015 05:31:57 -0500 Subject: [PATCH 2/2] Applied fixes from StyleCI --- app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php b/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php index d1c45aea..e832a003 100644 --- a/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php +++ b/app/TeenQuotes/AdminPanel/AdminPanelServiceProvider.php @@ -38,7 +38,7 @@ private function registerRoutes() $controller = $this->getController(); - $this->app['router']->group($this->getRouteGroupParams(), function () use($controller) { + $this->app['router']->group($this->getRouteGroupParams(), function () use ($controller) { $this->app['router']->get('/', ['uses' => $controller.'@index', 'as' => 'admin.quotes.index']); $this->app['router']->get('edit/{quote_id}', ['uses' => $controller.'@edit', 'as' => 'admin.quotes.edit']); $this->app['router']->put('update/{quote_id}', ['uses' => $controller.'@update', 'as' => 'admin.quotes.update']);