Passed
Push — master ( 0378d7...bd60cc )
by
04:19
created

FaqCategory::scopeSortAsc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Qsnh/meedu.
5
 *
6
 * (c) XiaoTeng <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace App\Models;
13
14
use Illuminate\Database\Eloquent\Model;
15
16
class FaqCategory extends Model
17
{
18
    protected $table = 'faq_categories';
19
20
    protected $fillable = [
21
        'name', 'sort',
22
    ];
23
24
    protected $appends = [
25
        'edit_url', 'destroy_url',
26
    ];
27
28
    /**
29
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
30
     */
31
    public function articles()
32
    {
33
        return $this->hasMany(FaqArticle::class, 'category_id');
34
    }
35
36
    /**
37
     * 作用域:排序.
38
     *
39
     * @param $query
40
     *
41
     * @return mixed
42
     */
43
    public function scopeSortAsc($query)
44
    {
45
        return $query->orderBy('sort');
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getEditUrlAttribute()
52
    {
53
        return route('backend.faq.category.edit', $this);
0 ignored issues
show
Bug introduced by
$this of type App\Models\FaqCategory is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

53
        return route('backend.faq.category.edit', /** @scrutinizer ignore-type */ $this);
Loading history...
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getDestroyUrlAttribute()
60
    {
61
        return route('backend.faq.category.destroy', $this);
0 ignored issues
show
Bug introduced by
$this of type App\Models\FaqCategory is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

61
        return route('backend.faq.category.destroy', /** @scrutinizer ignore-type */ $this);
Loading history...
62
    }
63
}
64