BannerRepository.php 732 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\Banner;
  4. /**
  5. * Created by PhpStorm.
  6. * User: durong
  7. * Date: 2019/6/15
  8. * Time: 下午5:39
  9. */
  10. class BannerRepository
  11. {
  12. public function __construct(Banner $banner)
  13. {
  14. $this->banner = $banner;
  15. }
  16. public function bannerData($request)
  17. {
  18. $where = [];
  19. $ids = explode(",", $request['ids']);
  20. $bannerLists = $this->banner
  21. ->where($where)
  22. ->get();
  23. $banner_data = [];
  24. foreach ($ids as $v){
  25. foreach ($bannerLists as $value){
  26. if($v == $value['id']){
  27. $banner_data[] = $value;
  28. }
  29. }
  30. }
  31. return $banner_data;
  32. }
  33. }