Passed
Push — master ( 80c3d8...edf6f7 )
by Mihail
10:42
created

LayoutFeatures::before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Apps\Model\Admin\LayoutFeatures;
4
5
use Apps\ActiveRecord\CommentPost;
6
use Apps\ActiveRecord\FeedbackPost;
7
use Ffcms\Core\Arch\Model;
8
use Illuminate\Support\Collection;
9
10
/**
11
 * Class LayoutFeatures. Basic admin layout features for last feedback queries, comments, etc
12
 * @package Apps\Model\Admin\LayoutFeatures
13
 */
14
class LayoutFeatures extends Model
15
{
16
    private $_feedback;
17
    private $_comments;
18
19
    /**
20
     * Process all database query before init
21
     */
22
    public function before()
23
    {
24
        $this->_feedback = FeedbackPost::where('closed', false)
25
            ->where('readed', false)
26
            ->orderBy('id', 'DESC')
27
            ->take(10)
28
            ->get();
29
30
        $this->_comments = CommentPost::orderBy('id', 'DESC')
31
            ->take(10)
32
            ->get();
33
34
        parent::before();
35
    }
36
37
    /**
38
     * Get feedback post array
39
     * @return FeedbackPost[]|Collection
40
     */
41
    public function getFeedback()
42
    {
43
        return $this->_feedback;
44
    }
45
46
    /**
47
     * Get comment post array
48
     * @return CommentPost|Collection
49
     */
50
    public function getComments()
51
    {
52
        return $this->_comments;
53
    }
54
}