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

BlogCategory::posts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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