TagPresenter.php 520 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Presenters;
  3. use App\Models\Article;
  4. use App\Models\Tag;
  5. /**
  6. * Class TagPresenter
  7. *
  8. * @package namespace App\Presenters;
  9. */
  10. class TagPresenter
  11. {
  12. public function tagNameList(Article $article)
  13. {
  14. $tag = $article->tag()->pluck('tag_name');
  15. return $tag ? implode(';', $tag->toArray()) : '';
  16. }
  17. /**
  18. * 获取标签列表
  19. *
  20. * @return mixed
  21. */
  22. public function tagList()
  23. {
  24. return Tag::query()->get(['id', 'tag_name']);
  25. }
  26. }