Article.php 586 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Models;
  3. class Article extends BaseModel
  4. {
  5. protected $fillable = [
  6. 'title', 'belong', 'txt', 'text', 'cover', 'keywords'
  7. ];
  8. public function getBelongAttribute($value)
  9. {
  10. return $this->belongFormat($value);
  11. }
  12. public function getTwoArticlesFromMenuId($menu_id)
  13. {
  14. return $this->whereRaw('find_in_set('.$menu_id.', belong)')
  15. ->orderBy('created_at', 'desc')
  16. ->take(2)
  17. ->get();
  18. }
  19. public function getArticlesFromMenuId($menu_id)
  20. {
  21. return $this->getFromMenuId($menu_id);
  22. }
  23. }