PlatformContentRepository.php 746 B

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