Code Duplication    Length = 49-49 lines in 2 locations

app/Models/Category.php 1 location

@@ 7-55 (lines=49) @@
4
use Eloquence\Behaviours\Sluggable;
5
use Xetaravel\Models\Presenters\CategoryPresenter;
6
7
class Category extends Model
8
{
9
    use Sluggable,
10
        CategoryPresenter;
11
12
    /**
13
     * The accessors to append to the model's array form.
14
     *
15
     * @var array
16
     */
17
    protected $appends = [
18
        'category_url'
19
    ];
20
21
    /**
22
     * The "booting" method of the model.
23
     *
24
     * @return void
25
     */
26
    protected static function boot()
27
    {
28
        parent::boot();
29
30
        // Generated the slug before updating.
31
        static::updating(function ($model) {
32
            $model->generateSlug();
33
        });
34
    }
35
36
    /**
37
     * Return the field to slug.
38
     *
39
     * @return string
40
     */
41
    public function slugStrategy(): string
42
    {
43
        return 'title';
44
    }
45
46
    /**
47
     * Get the articles for the category.
48
     *
49
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
50
     */
51
    public function articles()
52
    {
53
        return $this->hasMany(Article::class);
54
    }
55
}
56

app/Models/DiscussCategory.php 1 location

@@ 7-55 (lines=49) @@
4
use Eloquence\Behaviours\Sluggable;
5
use Xetaravel\Models\Presenters\DiscussCategoryPresenter;
6
7
class DiscussCategory extends Model
8
{
9
    use Sluggable,
10
        DiscussCategoryPresenter;
11
12
    /**
13
     * The accessors to append to the model's array form.
14
     *
15
     * @var array
16
     */
17
    protected $appends = [
18
        'category_url'
19
    ];
20
21
    /**
22
     * The "booting" method of the model.
23
     *
24
     * @return void
25
     */
26
    protected static function boot()
27
    {
28
        parent::boot();
29
30
        // Generated the slug before updating.
31
        static::updating(function ($model) {
32
            $model->generateSlug();
33
        });
34
    }
35
36
    /**
37
     * Return the field to slug.
38
     *
39
     * @return string
40
     */
41
    public function slugStrategy(): string
42
    {
43
        return 'title';
44
    }
45
46
    /**
47
     * Get the threads for the category.
48
     *
49
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
50
     */
51
    public function threads()
52
    {
53
        return $this->hasMany(DiscussThread::class);
54
    }
55
}
56