|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Terranet\Administrator\Dashboard\Panels; |
|
4
|
|
|
|
|
5
|
|
|
use DB; |
|
6
|
|
|
use Terranet\Administrator\Architect; |
|
7
|
|
|
use Terranet\Administrator\Dashboard\Panel; |
|
8
|
|
|
use Terranet\Administrator\Traits\Stringify; |
|
9
|
|
|
|
|
10
|
|
|
class MembersPanel extends Panel |
|
11
|
|
|
{ |
|
12
|
|
|
use Stringify; |
|
13
|
|
|
|
|
14
|
|
|
public function render() |
|
15
|
|
|
{ |
|
16
|
|
|
$weekAgo = \Carbon\Carbon::now()->subWeek(); |
|
17
|
|
|
$monthAgo = \Carbon\Carbon::now()->subMonth(); |
|
18
|
|
|
|
|
19
|
|
|
$total = $this->createModel()->count(); |
|
20
|
|
|
$signedLastWeek = $this->createModel() |
|
21
|
|
|
->where('created_at', '>=', $weekAgo)->count(); |
|
22
|
|
|
$signedLastMonth = $this->createModel() |
|
23
|
|
|
->where('created_at', '>=', $monthAgo)->count(); |
|
24
|
|
|
$signedStatistics = $this->createModel() |
|
25
|
|
|
->where('created_at', '>=', $monthAgo) |
|
26
|
|
|
->select([DB::raw('COUNT(id) AS cnt'), DB::raw('DATE(created_at) as dt')]) |
|
27
|
|
|
->groupBy('dt')->pluck('cnt', 'dt'); |
|
28
|
|
|
|
|
29
|
|
|
return view(Architect::template()->dashboard('members'), [ |
|
|
|
|
|
|
30
|
|
|
'total' => $total, |
|
31
|
|
|
'signed' => [ |
|
32
|
|
|
'lastWeek' => $signedLastWeek, |
|
33
|
|
|
'lastMonth' => $signedLastMonth, |
|
34
|
|
|
], |
|
35
|
|
|
'signedStatistics' => $signedStatistics, |
|
36
|
|
|
]); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return User |
|
|
|
|
|
|
41
|
|
|
*/ |
|
42
|
|
|
protected function createModel() |
|
43
|
|
|
{ |
|
44
|
|
|
$model = config('administrator.auth.model', '\App\User'); |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
return new $model(); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|