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
77ac9b34
Unverified
Commit
77ac9b34
authored
Oct 12, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding method to allow server side index & filtering
parent
e4df7bfe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
SentinelUserRepository.php
...les/User/Repositories/Sentinel/SentinelUserRepository.php
+36
-0
UserRepository.php
Modules/User/Repositories/UserRepository.php
+9
-0
No files found.
Modules/User/Repositories/Sentinel/SentinelUserRepository.php
View file @
77ac9b34
...
@@ -4,6 +4,9 @@ namespace Modules\User\Repositories\Sentinel;
...
@@ -4,6 +4,9 @@ namespace Modules\User\Repositories\Sentinel;
use
Cartalyst\Sentinel\Laravel\Facades\Activation
;
use
Cartalyst\Sentinel\Laravel\Facades\Activation
;
use
Cartalyst\Sentinel\Laravel\Facades\Sentinel
;
use
Cartalyst\Sentinel\Laravel\Facades\Sentinel
;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Hash
;
use
Modules\User\Entities\Sentinel\User
;
use
Modules\User\Entities\Sentinel\User
;
use
Modules\User\Events\UserHasRegistered
;
use
Modules\User\Events\UserHasRegistered
;
...
@@ -188,6 +191,39 @@ class SentinelUserRepository implements UserRepository
...
@@ -188,6 +191,39 @@ class SentinelUserRepository implements UserRepository
return
Sentinel
::
findByCredentials
(
$credentials
);
return
Sentinel
::
findByCredentials
(
$credentials
);
}
}
/**
* Paginating, ordering and searching through pages for server side index table
* @param Request $request
* @return LengthAwarePaginator
*/
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
{
$roles
=
$this
->
allWithBuilder
();
if
(
$request
->
get
(
'search'
)
!==
null
)
{
$term
=
$request
->
get
(
'search'
);
$roles
->
where
(
'first_name'
,
'LIKE'
,
"%
{
$term
}
%"
)
->
orWhere
(
'last_name'
,
'LIKE'
,
"%
{
$term
}
%"
)
->
orWhere
(
'email'
,
'LIKE'
,
"%
{
$term
}
%"
)
->
orWhere
(
'id'
,
$term
);
}
if
(
$request
->
get
(
'order_by'
)
!==
null
&&
$request
->
get
(
'order'
)
!==
'null'
)
{
$order
=
$request
->
get
(
'order'
)
===
'ascending'
?
'asc'
:
'desc'
;
$roles
->
orderBy
(
$request
->
get
(
'order_by'
),
$order
);
}
else
{
$roles
->
orderBy
(
'created_at'
,
'desc'
);
}
return
$roles
->
paginate
(
$request
->
get
(
'per_page'
,
10
));
}
public
function
allWithBuilder
()
:
Builder
{
return
$this
->
user
->
newQuery
();
}
/**
/**
* Hash the password key
* Hash the password key
* @param array $data
* @param array $data
...
...
Modules/User/Repositories/UserRepository.php
View file @
77ac9b34
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
Modules\User\Repositories
;
namespace
Modules\User\Repositories
;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Http\Request
;
use
Modules\User\Entities\UserInterface
;
use
Modules\User\Entities\UserInterface
;
/**
/**
...
@@ -78,4 +80,11 @@ interface UserRepository
...
@@ -78,4 +80,11 @@ interface UserRepository
* @return mixed
* @return mixed
*/
*/
public
function
findByCredentials
(
array
$credentials
);
public
function
findByCredentials
(
array
$credentials
);
/**
* Paginating, ordering and searching through pages for server side index table
* @param Request $request
* @return LengthAwarePaginator
*/
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
;
}
}
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