BlogCategory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 44
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A slugStrategy() 0 3 1
A articles() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models;
6
7
use Eloquence\Behaviours\HasSlugs;
8
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
9
use Illuminate\Database\Eloquent\Relations\HasMany;
10
use Xetaravel\Models\Presenters\BlogCategoryPresenter;
11
use Xetaravel\Observers\BlogCategoryObserver;
12
13
#[ObservedBy([BlogCategoryObserver::class])]
14
class BlogCategory extends Model
15
{
16
    use BlogCategoryPresenter;
0 ignored issues
show
Bug introduced by
The trait Xetaravel\Models\Presenters\BlogCategoryPresenter requires the property $slug which is not provided by Xetaravel\Models\BlogCategory.
Loading history...
17
    use HasSlugs;
18
19
    /**
20
     * The attributes that are mass assignable.
21
     *
22
     * @var array
23
     */
24
    protected $fillable = [
25
        'title',
26
        'slug',
27
        'description'
28
    ];
29
30
    /**
31
     * The accessors to append to the model's array form.
32
     *
33
     * @var array
34
     */
35
    protected $appends = [
36
        'show_url'
37
    ];
38
39
    /**
40
     * Return the field to slug.
41
     *
42
     * @return string
43
     */
44
    public function slugStrategy(): string
45
    {
46
        return 'title';
47
    }
48
49
    /**
50
     * Get the articles for the category.
51
     *
52
     * @return HasMany
53
     */
54
    public function articles(): HasMany
55
    {
56
        return $this->hasMany(BlogArticle::class);
57
    }
58
}
59