CategoryMajorRepository.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\CategoryMajor;
  4. use Prettus\Repository\Eloquent\BaseRepository;
  5. use Prettus\Repository\Criteria\RequestCriteria;
  6. /**
  7. * Class MemberRepositoryEloquent.
  8. *
  9. * @package namespace App\Repositories;
  10. */
  11. class CategoryMajorRepository extends BaseRepository
  12. {
  13. /**
  14. * Specify Model class name
  15. *
  16. * @return string
  17. */
  18. public function model()
  19. {
  20. return CategoryMajor::class;
  21. }
  22. /**
  23. * Boot up the repository, pushing criteria
  24. */
  25. public function boot()
  26. {
  27. $this->pushCriteria(app(RequestCriteria::class));
  28. }
  29. /**
  30. * @param $id
  31. * @return mixed
  32. */
  33. public function getCategoryMajor($id)
  34. {
  35. return $this->model->find($id);
  36. }
  37. public function getCategoryById($parent = 0)
  38. {
  39. return $this->model->where(['parent_id'=>$parent])->select(['id','name','parent_id'])->get()->toArray();
  40. }
  41. public function getMajorList()
  42. {
  43. return $this->model->select(['id','name','parent_id'])->get()->toArray();
  44. }
  45. }