Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
9d5bcad6
Unverified
Commit
9d5bcad6
authored
Sep 18, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create route and controller to change page status
parent
c6ea85c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
UpdatePageStatusController.php
.../Page/Http/Controllers/Api/UpdatePageStatusController.php
+38
-0
apiRoutes.php
Modules/Page/Http/apiRoutes.php
+5
-0
No files found.
Modules/Page/Http/Controllers/Api/UpdatePageStatusController.php
0 → 100644
View file @
9d5bcad6
<?php
namespace
Modules\Page\Http\Controllers\Api
;
use
Illuminate\Http\Request
;
use
Illuminate\Routing\Controller
;
use
Modules\Page\Repositories\PageRepository
;
class
UpdatePageStatusController
extends
Controller
{
/**
* @var PageRepository
*/
private
$page
;
public
function
__construct
(
PageRepository
$page
)
{
$this
->
page
=
$page
;
}
public
function
__invoke
(
Request
$request
)
{
$pageIds
=
json_decode
(
$request
->
get
(
'pageIds'
));
$this
->
handleAction
(
$request
->
get
(
'action'
),
$pageIds
);
return
response
()
->
json
([
'errors'
=>
false
,
'message'
=>
'Pages were updated'
]);
}
private
function
handleAction
(
string
$action
,
array
$pageIds
)
{
if
(
$action
===
'mark-online'
)
{
return
$this
->
page
->
markMultipleAsOnlineInAllLocales
(
$pageIds
);
}
return
$this
->
page
->
markMultipleAsOfflineInAllLocales
(
$pageIds
);
}
}
Modules/Page/Http/apiRoutes.php
View file @
9d5bcad6
...
...
@@ -18,6 +18,11 @@ $router->group(['prefix' => '/page', 'middleware' => ['api.token', 'auth.admin']
'uses'
=>
'PageController@indexServerSide'
,
'middleware'
=>
'token-can:page.pages.index'
,
]);
$router
->
get
(
'mark-pages-status'
,
[
'as'
=>
'api.page.page.mark-status'
,
'uses'
=>
'UpdatePageStatusController'
,
'middleware'
=>
'token-can:page.pages.edit'
,
]);
$router
->
delete
(
'pages/{page}'
,
[
'as'
=>
'api.page.page.destroy'
,
'uses'
=>
'PageController@destroy'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment