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
9ff02cc6
Unverified
Commit
9ff02cc6
authored
Sep 10, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding method to get all records returned as query builder
parent
12da7a11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
BaseRepository.php
Modules/Core/Repositories/BaseRepository.php
+7
-0
EloquentBaseRepository.php
...les/Core/Repositories/Eloquent/EloquentBaseRepository.php
+13
-0
No files found.
Modules/Core/Repositories/BaseRepository.php
View file @
9ff02cc6
...
...
@@ -2,6 +2,8 @@
namespace
Modules\Core\Repositories
;
use
Illuminate\Database\Eloquent\Builder
;
/**
* Interface CoreRepository
* @package Modules\Core\Repositories
...
...
@@ -20,6 +22,11 @@ interface BaseRepository
*/
public
function
all
();
/**
* @return Builder
*/
public
function
allWithBuilder
()
:
Builder
;
/**
* Paginate the model to $perPage items per page
* @param int $perPage
...
...
Modules/Core/Repositories/Eloquent/EloquentBaseRepository.php
View file @
9ff02cc6
...
...
@@ -50,6 +50,19 @@ abstract class EloquentBaseRepository implements BaseRepository
return
$this
->
model
->
orderBy
(
'created_at'
,
'DESC'
)
->
get
();
}
/**
* @inheritdoc
*/
public
function
allWithBuilder
()
:
Builder
{
if
(
method_exists
(
$this
->
model
,
'translations'
))
{
return
$this
->
model
->
with
(
'translations'
)
->
orderBy
(
'created_at'
,
'DESC'
);
}
return
$this
->
model
->
orderBy
(
'created_at'
,
'DESC'
);
}
/**
* @inheritdoc
*/
...
...
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