Adding route to update a page

parent 511b2984
......@@ -2,10 +2,10 @@
namespace Modules\Page\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\Page\Entities\Page;
use Modules\Page\Http\Requests\CreatePageRequest;
use Modules\Page\Http\Requests\UpdatePageRequest;
use Modules\Page\Repositories\PageRepository;
use Modules\Page\Transformers\FullPageTransformer;
use Modules\Page\Transformers\PageTransformer;
......@@ -42,6 +42,16 @@ class PageController extends Controller
return new FullPageTransformer($page);
}
public function update(Page $page, UpdatePageRequest $request)
{
$this->page->update($page, $request->all());
return response()->json([
'errors' => false,
'message' => trans('page::messages.page updated'),
]);
}
public function destroy(Page $page)
{
$this->page->destroy($page);
......
......@@ -28,5 +28,10 @@ $router->group(['prefix' => '/page'], function (Router $router) {
'uses' => 'PageController@find',
'middleware' => 'token-can:page.pages.edit',
]);
$router->post('pages/{page}/edit', [
'as' => 'api.page.page.update',
'uses' => 'PageController@update',
'middleware' => 'token-can:page.pages.edit',
]);
$router->get('templates', 'PageTemplatesController')->name('api.page.page-templates.index');
});
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