Completed
Push — master ( 876046...6e04bc )
by Joao
02:55
created

BlogCategory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPostsModel() 0 4 1
A setPostsModel() 0 4 1
A posts() 0 4 1
1
<?php namespace jlourenco\blog\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
use jlourenco\support\Traits\Creation;
5
6
class BlogCategory extends Model
7
{
8
9
    /**
10
     * To allow user actions identity (Created_by, Updated_by, Deleted_by)
11
     */
12
    use Creation;
13
14
    /**
15
     * {@inheritDoc}
16
     */
17
    protected $table = 'BlogCategory';
18
19
    /**
20
     * {@inheritDoc}
21
     */
22
    protected $fillable = [
23
        'name',
24
        'description'
25
    ];
26
27
    /**
28
     * The Blog post model name.
29
     *
30
     * @var string
31
     */
32
    protected static $postsModel = 'jlourenco\blog\Models\BlogPost';
33
34
    /**
35
     * Returns the post model.
36
     *
37
     * @return string
38
     */
39
    public static function getPostsModel()
40
    {
41
        return static::$postsModel;
42
    }
43
44
    /**
45
     * Sets the post model.
46
     *
47
     * @param  string  $postsModel
48
     * @return void
49
     */
50
    public static function setPostsModel($postsModel)
51
    {
52
        static::$postsModel = $postsModel;
53
    }
54
55
    public function posts()
56
    {
57
        return $this->hasMany(static::$postsModel, 'category');
58
    }
59
60
}
61