BlogCategory::getPostsModel()   A
last analyzed

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 Illuminate\Database\Eloquent\SoftDeletes;
5
use jlourenco\support\Traits\Creation;
6
use jlourenco\support\Traits\Sluggable;
7
8
class BlogCategory extends Model
9
{
10
11
    /**
12
     * To allow user actions identity (Created_by, Updated_by, Deleted_by)
13
     */
14
    use Creation;
15
16
    use Sluggable;
17
18
    use SoftDeletes;
19
20
    /**
21
     * {@inheritDoc}
22
     */
23
    protected $table = 'BlogCategory';
24
25
    /**
26
     * {@inheritDoc}
27
     */
28
    protected $fillable = [
29
        'name',
30
        'description',
31
        'slug'
32
    ];
33
34
    protected $dates = [ 'created_at', 'deleted_at'];
35
36
    /**
37
     * The Blog post model name.
38
     *
39
     * @var string
40
     */
41
    protected static $postsModel = 'jlourenco\blog\Models\BlogPost';
42
43
    /**
44
     * Returns the post model.
45
     *
46
     * @return string
47
     */
48
    public static function getPostsModel()
49
    {
50
        return static::$postsModel;
51
    }
52
53
    /**
54
     * Sets the post model.
55
     *
56
     * @param  string  $postsModel
57
     * @return void
58
     */
59
    public static function setPostsModel($postsModel)
60
    {
61
        static::$postsModel = $postsModel;
62
    }
63
64
    public function posts()
65
    {
66
        return $this->hasMany(static::$postsModel, 'category');
67
    }
68
69
}
70