HrtoolsCategoryRepository.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\HrtoolsCategory;
  4. use Prettus\Repository\Eloquent\BaseRepository;
  5. /**
  6. * Class HrtoolsCategoryRepositoryEloquent.
  7. *
  8. * @package namespace App\Repositories;
  9. */
  10. class HrtoolsCategoryRepository extends BaseRepository
  11. {
  12. /**
  13. * Specify Model class name
  14. *
  15. * @return string
  16. */
  17. public function model()
  18. {
  19. return HrtoolsCategory::class;
  20. }
  21. public function getLists($where)
  22. {
  23. $lists = $this->model->where($where)->orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->get();
  24. if ($lists->toArray()) {
  25. foreach ($lists as $k => $v) {
  26. if ($v->category_img) {
  27. $lists[$k]->category_img = upload_asset($v->category_img);
  28. } else {
  29. $lists[$k]->category_img = theme_asset('app/images/hrtools_img/'.$v->id.'.jpg');
  30. }
  31. }
  32. }
  33. if (array_key_exists('id', $where)) {
  34. $lists = $lists[0];
  35. }
  36. return $lists;
  37. }
  38. }