Article.php 567 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * 文章.
  7. */
  8. class Article extends Model
  9. {
  10. use SoftDeletes;
  11. protected $table = 'article';
  12. protected $casts = ['deleted_at' => 'datetime'];
  13. protected $guarded = [];
  14. // 筛选类型
  15. public function scopeType($query, $type)
  16. {
  17. return $query->whereType($type);
  18. }
  19. public function scopeLang($query, $language = null)
  20. {
  21. return $query->whereLanguage($language ?? app()->getLocale());
  22. }
  23. }