|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Apps\Model\Admin\Stats; |
|
4
|
|
|
|
|
5
|
|
|
use Apps\ActiveRecord\CommentAnswer; |
|
6
|
|
|
use Apps\ActiveRecord\CommentPost; |
|
7
|
|
|
use Apps\ActiveRecord\Content; |
|
8
|
|
|
use Apps\ActiveRecord\FeedbackPost; |
|
9
|
|
|
use Ffcms\Core\Arch\Model; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class EntityNotificationStats. Short statistic for admin layout main |
|
13
|
|
|
* @package Apps\Model\Admin\Stats |
|
14
|
|
|
*/ |
|
15
|
|
|
class EntityNotificationStats extends Model |
|
16
|
|
|
{ |
|
17
|
|
|
public $contents; |
|
18
|
|
|
public $feedback; |
|
19
|
|
|
public $comments; |
|
20
|
|
|
|
|
21
|
|
|
public $total; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Calculate notification statistics |
|
25
|
|
|
*/ |
|
26
|
|
|
public function before() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->calcContentsModerate(); |
|
29
|
|
|
$this->calcNewFeedback(); |
|
30
|
|
|
$this->calcCommentsModerate(); |
|
31
|
|
|
|
|
32
|
|
|
$this->total = $this->contents + $this->feedback + $this->comments; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Calculate content on moderation |
|
37
|
|
|
*/ |
|
38
|
|
|
private function calcContentsModerate() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->contents = Content::where('display', '=', 0)->count(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Calculate unreaded feedback |
|
45
|
|
|
*/ |
|
46
|
|
|
private function calcNewFeedback() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->feedback = FeedbackPost::where('readed', '=', 0)->where('closed', '=', 0)->count(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Calculate comments on moderation |
|
53
|
|
|
*/ |
|
54
|
|
|
private function calcCommentsModerate() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->comments = CommentPost::where('moderate', '=', 1)->count(); |
|
57
|
|
|
$this->comments += CommentAnswer::where('moderate', '=', 1)->count(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
} |