DistributorService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @Name
  4. * @Description
  5. * @Author 刘学玺
  6. * @Date 2023/11/23 20:57
  7. */
  8. namespace App\Http\Services\Admin\Channel;
  9. use App\Http\Services\BaseService;
  10. use App\Models\Distributor;
  11. use App\Models\Menu;
  12. class DistributorService extends BaseService
  13. {
  14. public function index($data)
  15. {
  16. $model = $this->queryCondition(Distributor::query(), $data);
  17. $list = $model->latest('id')
  18. ->paginate($data['pageSize'])
  19. ->toArray();
  20. return $this->apiSuccess('', [
  21. 'list' => $list['data'],
  22. 'total' => $list['total']
  23. ]);
  24. }
  25. public function all()
  26. {
  27. $model = $this->queryCondition(Distributor::query(), []);
  28. $list = $model->latest('id')->select('id', 'name')->get()
  29. ->toArray();
  30. return $this->apiSuccess('', [
  31. 'list' => $list,
  32. ]);
  33. }
  34. public function store(array $data)
  35. {
  36. return $this->commonCreate(Menu::query(), $data);
  37. }
  38. public function detail($id)
  39. {
  40. $data = Menu::query()->find($id)->toArray();
  41. return $this->apiSuccess('', $data);
  42. }
  43. public function update(array $data)
  44. {
  45. return $this->commonUpdate(Menu::query(), $data['id'], $data);
  46. }
  47. }