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
0c259bb6
Unverified
Commit
0c259bb6
authored
Sep 18, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding method to mark all given pageids as online
parent
7ca5e262
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
CachePageDecorator.php
Modules/Page/Repositories/Cache/CachePageDecorator.php
+11
-0
EloquentPageRepository.php
...les/Page/Repositories/Eloquent/EloquentPageRepository.php
+17
-0
PageRepository.php
Modules/Page/Repositories/PageRepository.php
+6
-0
EloquentPageRepositoryTest.php
Modules/Page/Tests/EloquentPageRepositoryTest.php
+32
-0
No files found.
Modules/Page/Repositories/Cache/CachePageDecorator.php
View file @
0c259bb6
...
@@ -90,4 +90,15 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
...
@@ -90,4 +90,15 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
}
}
);
);
}
}
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
)
{
$this
->
clearCache
();
$this
->
markAsOnlineInAllLocales
(
$pageId
);
}
}
}
Modules/Page/Repositories/Eloquent/EloquentPageRepository.php
View file @
0c259bb6
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories\Eloquent;
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories\Eloquent;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Mcamara\LaravelLocalization\LaravelLocalization
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Page\Events\PageIsCreating
;
use
Modules\Page\Events\PageIsCreating
;
use
Modules\Page\Events\PageIsUpdating
;
use
Modules\Page\Events\PageIsUpdating
;
...
@@ -171,4 +172,20 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
...
@@ -171,4 +172,20 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
// ->groupBy('page__pages.id')->orderBy("t.title", 'desc');
// ->groupBy('page__pages.id')->orderBy("t.title", 'desc');
return
$pages
->
paginate
(
$request
->
get
(
'per_page'
,
10
));
return
$pages
->
paginate
(
$request
->
get
(
'per_page'
,
10
));
}
}
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
)
{
$page
=
$this
->
find
(
$pageId
);
$data
=
[];
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
$data
[
$locale
]
=
[
'status'
=>
1
];
}
return
$this
->
update
(
$page
,
$data
);
}
}
}
Modules/Page/Repositories/PageRepository.php
View file @
0c259bb6
...
@@ -33,4 +33,10 @@ interface PageRepository extends BaseRepository
...
@@ -33,4 +33,10 @@ interface PageRepository extends BaseRepository
* @return LengthAwarePaginator
* @return LengthAwarePaginator
*/
*/
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
;
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
;
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
);
}
}
Modules/Page/Tests/EloquentPageRepositoryTest.php
View file @
0c259bb6
...
@@ -188,6 +188,17 @@ class EloquentPageRepositoryTest extends BasePageTest
...
@@ -188,6 +188,17 @@ class EloquentPageRepositoryTest extends BasePageTest
});
});
}
}
/** @test */
public
function
it_can_mark_page_as_online_in_all_locales
()
{
$page
=
$this
->
createRandomPage
([
'en'
=>
[
'status'
=>
0
],
'fr'
=>
[
'status'
=>
0
]]);
$page
=
$this
->
page
->
markAsOnlineInAllLocales
(
$page
->
id
);
$this
->
assertTrue
(
$page
->
translate
(
'en'
)
->
status
);
$this
->
assertTrue
(
$page
->
translate
(
'fr'
)
->
status
);
}
private
function
createPage
()
private
function
createPage
()
{
{
return
$this
->
page
->
create
([
return
$this
->
page
->
create
([
...
@@ -200,4 +211,25 @@ class EloquentPageRepositoryTest extends BasePageTest
...
@@ -200,4 +211,25 @@ class EloquentPageRepositoryTest extends BasePageTest
],
],
]);
]);
}
}
private
function
createRandomPage
(
array
$properties
)
{
$faker
=
\Faker\Factory
::
create
();
$data
=
[
'is_home'
=>
0
,
'template'
=>
'default'
,
'en'
=>
[
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
'fr'
=>
[
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
];
return
$this
->
page
->
create
(
$data
+
$properties
);
}
}
}
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