Skip to content

Commit 9bb4ff7

Browse files
committed
some improvements
1 parent 527ba71 commit 9bb4ff7

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

src/Darryldecode/Backend/Components/ContentBuilder/Commands/QueryContentsCommand.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class QueryContentsCommand extends Command implements SelfHandling {
5252
* @var null
5353
*/
5454
private $authorId;
55+
/**
56+
* @var null
57+
*/
58+
private $startDate;
59+
/**
60+
* @var null
61+
*/
62+
private $endDate;
5563

5664
/**
5765
* @param null $type
@@ -64,6 +72,8 @@ class QueryContentsCommand extends Command implements SelfHandling {
6472
* @param string $sortBy
6573
* @param string $sortOrder
6674
* @param bool $disablePermissionChecking
75+
* @param null $startDate
76+
* @param null $endDate
6777
*/
6878
public function __construct($type = null,
6979
$status = 'any',
@@ -74,7 +84,9 @@ public function __construct($type = null,
7484
$perPage = 8,
7585
$sortBy = 'created_at',
7686
$sortOrder = 'DESC',
77-
$disablePermissionChecking = false)
87+
$disablePermissionChecking = false,
88+
$startDate = null,
89+
$endDate = null)
7890
{
7991
parent::__construct();
8092
$this->type = $type;
@@ -88,6 +100,8 @@ public function __construct($type = null,
88100
$this->authorId = $authorId;
89101
$this->args = get_defined_vars();
90102
$this->disablePermissionChecking = $disablePermissionChecking;
103+
$this->startDate = $startDate;
104+
$this->endDate = $endDate;
91105
}
92106

93107
/**
@@ -185,6 +199,17 @@ protected function query($contentType, $content)
185199
}
186200
}
187201

202+
// setup date ranges
203+
if( !is_null($this->startDate) && ($this->startDate!='') )
204+
{
205+
$q->ofStartDate($this->startDate);
206+
}
207+
if( !is_null($this->endDate) && ($this->endDate!='') )
208+
{
209+
$q->ofEndDate($this->endDate);
210+
}
211+
212+
// decide whether request wants paginated version or not
188213
if( $this->paginated )
189214
{
190215
$res = $q->paginate($this->perPage);

src/Darryldecode/Backend/Components/ContentBuilder/Models/Content.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,30 @@ public function revisions()
148148
{
149149
return $this->hasMany('Darryldecode\Backend\Components\ContentBuilder\Models\ContentRevisions','content_id');
150150
}
151+
152+
/**
153+
* Scope for start date
154+
*
155+
* @param $query
156+
* @param $startDate
157+
* @return bool
158+
*/
159+
public function scopeOfStartDate($query, $startDate)
160+
{
161+
if( $startDate === false ) return false;
162+
return $query->where('created_at','>=',$startDate);
163+
}
164+
165+
/**
166+
* scope for end date
167+
*
168+
* @param $query
169+
* @param $endDate
170+
* @return bool
171+
*/
172+
public function scopeOfEndDate($query, $endDate)
173+
{
174+
if( $endDate === false ) return false;
175+
return $query->where('created_at','<=',$endDate);
176+
}
151177
}

src/Darryldecode/Backend/Components/User/Views/users.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<div class="table-responsive animated fadeIn">
2323
<table class="table table-hover">
2424
<tr>
25+
<th>ID</th>
2526
<th>Name</th>
2627
<th>Email</th>
2728
<th colspan="2" class="action text-center"><i class="fa fa-bolt"></i></th>
@@ -30,6 +31,7 @@
3031
<td colspan="4" class="text-center">Loading <i class="fa fa-spinner fa-spin"></i></td>
3132
</tr>
3233
<tr data-ng-repeat="u in users.data" class="user-item-@{{::$index}}" >
34+
<td>[@{{::u.id}}]</td>
3335
<td><i class="fa fa-user"></i> @{{::u.first_name}} @{{::u.last_name}}</td>
3436
<td>@{{::u.email}}</td>
3537
<td class="action text-center">

0 commit comments

Comments
 (0)