Skip to content

Commit

Permalink
Creating api route to list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Sep 11, 2017
1 parent 4617d73 commit 4040ae1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Modules/Page/Http/Controllers/Api/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Routing\Controller;
use Modules\Page\Entities\Page;
use Modules\Page\Repositories\PageRepository;
use Modules\Page\Transformers\PageTransformer;

class PageController extends Controller
{
Expand All @@ -18,7 +19,12 @@ public function __construct(PageRepository $page)
$this->page = $page;
}

public function destroy($page)
public function index()
{
return PageTransformer::collection($this->page->all());
}

public function destroy(Page $page)
{
$this->page->destroy($page);

Expand Down
5 changes: 5 additions & 0 deletions Modules/Page/Http/apiRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
});

$router->group(['prefix' => '/page'], function (Router $router) {
$router->get('pages', [
'as' => 'api.page.page.index',
'uses' => 'PageController@index',
'middleware' => 'token-can:page.pages.index',
]);
$router->delete('pages/{page}', [
'as' => 'api.page.page.destroy',
'uses' => 'PageController@destroy',
Expand Down

0 comments on commit 4040ae1

Please sign in to comment.