SitePages.php 721 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Distributor\Repositories;
  3. use App\Models\SitePages as Model;
  4. use Dcat\Admin\Repositories\EloquentRepository;
  5. class SitePages extends EloquentRepository
  6. {
  7. /**
  8. * Model.
  9. *
  10. * @var string
  11. */
  12. protected $eloquentClass = Model::class;
  13. /*
  14. * 查找最新的N个文章
  15. */
  16. public static function selectOptionsNew($limit=30)
  17. {
  18. return Model::where('dist_id', getDistributorId())->where('status', 1)->orderBy('created_at', 'desc')->limit($limit)->pluck('title', 'id');
  19. }
  20. /*
  21. * 获取一个标签
  22. */
  23. public static function getOneById($id)
  24. {
  25. return Model::where('id', $id)->where('dist_id', getDistributorId())->first();
  26. }
  27. }