| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getEditUrlAttribute() |
||
| 52 | { |
||
| 53 | return route('backend.faq.category.edit', $this); |
||
|
|
|||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getDestroyUrlAttribute() |
||
| 62 | } |
||
| 63 | } |
||
| 64 |