CompanyContactRepository.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\CompanyContact;
  4. use Prettus\Repository\Eloquent\BaseRepository;
  5. /**
  6. * Class CompanyContactRepositoryEloquent.
  7. *
  8. * @package namespace App\Repositories;
  9. */
  10. class CompanyContactRepository extends BaseRepository
  11. {
  12. /**
  13. * Specify Model class name
  14. *
  15. * @return string
  16. */
  17. public function model()
  18. {
  19. return CompanyContact::class;
  20. }
  21. public function getList($where, $page_num = '')
  22. {
  23. $rst = $this->model->where($where)->orderBy('updated_at', 'desc');
  24. if ($page_num) {
  25. return $rst->paginate($page_num);
  26. } else {
  27. return $rst->get();
  28. }
  29. }
  30. public function deleteContact($where, $whereIn = array())
  31. {
  32. $rst = $this->model->where($where);
  33. if ($whereIn) {
  34. foreach ($whereIn as $k => $v) {
  35. $rst->whereIn($k, $v);
  36. }
  37. }
  38. return $rst->delete();
  39. }
  40. public function getContact($where)
  41. {
  42. return $this->model->where($where)->first();
  43. }
  44. public function save($data, $id)
  45. {
  46. return $this->update($data, $id);
  47. }
  48. public function ContactUpdate($where,$data){
  49. return $this->model->where($where)->update($data);
  50. }
  51. }