Creating api route to list pages

parent 4617d732
......@@ -5,6 +5,7 @@ namespace Modules\Page\Http\Controllers\Api;
use Illuminate\Routing\Controller;
use Modules\Page\Entities\Page;
use Modules\Page\Repositories\PageRepository;
use Modules\Page\Transformers\PageTransformer;
class PageController extends Controller
{
......@@ -18,7 +19,12 @@ class PageController extends Controller
$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);
......
......@@ -8,6 +8,11 @@ $router->bind('page', function ($id) {
});
$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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment