StarNewsRepository.php 691 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\StarNews;
  4. use Dingo\Api\Http\Response;
  5. use Symfony\Component\HttpKernel\Exception\HttpException;
  6. /**
  7. * Created by PhpStorm.
  8. * User: durong
  9. * Date: 2019/6/17
  10. * Time: 下午18:59
  11. */
  12. class StarNewsRepository
  13. {
  14. public function __construct(StarNews $starNews)
  15. {
  16. $this->starNews = $starNews;
  17. }
  18. public function index($request)
  19. {
  20. if (isset($request['id'])){
  21. return $this->starNews
  22. ->where('id',$request['id'])->orderBy('id', 'desc')->first();
  23. }
  24. $this->starNews = $this->starNews
  25. ->orderBy('id', 'desc')->get();
  26. return $this->starNews;
  27. }
  28. }