CompanyImgRepository.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2018/11/13
  6. * Time: 17:47
  7. */
  8. namespace App\Repositories;
  9. use App\Models\CompanyImg;
  10. use Prettus\Repository\Eloquent\BaseRepository;
  11. use Prettus\Repository\Criteria\RequestCriteria;
  12. class CompanyImgRepository extends BaseRepository
  13. {
  14. public function model()
  15. {
  16. return CompanyImg::class;
  17. }
  18. public function boot()
  19. {
  20. $this->pushCriteria(app(RequestCriteria::class));
  21. }
  22. public function list($id)
  23. {
  24. return $this->findWhere(['company_id'=>$id]);
  25. }
  26. public function getImgInfo($id)
  27. {
  28. return $this->find($id);
  29. }
  30. /**
  31. * @企业风采保存
  32. * @param $data
  33. * @return mixed
  34. * @throws \Prettus\Validator\Exceptions\ValidatorException
  35. */
  36. public function store($data)
  37. {
  38. return $this->create($data);
  39. }
  40. public function imgCount()
  41. {
  42. return $this->model->where('company_id', auth('web-company')->user()->id)->count();
  43. }
  44. public function saveRemark($data, $where)
  45. {
  46. return $this->model->where($where)->update($data);
  47. }
  48. public function delImg($id,$company_id)
  49. {
  50. return $this->deleteWhere(['company_id'=>$company_id,'id'=>$id]);
  51. }
  52. public function getImages($where)
  53. {
  54. return $this->model->where($where)->get();
  55. }
  56. public function getCount($subsite_id, $orwhere)
  57. {
  58. return $this->model->when($subsite_id,function ($query) use($subsite_id) {
  59. $query->whereHas('companys', function ($query) use($subsite_id) {
  60. $query->where($subsite_id);
  61. });
  62. })->whereHas('companys')->WhereIn('audit', $orwhere)->count();
  63. }
  64. }