CoachController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @Name
  4. * @Description
  5. * @Author 刘学玺
  6. * @Date 2024/9/13 17:20
  7. */
  8. namespace App\Http\Controllers\Frontend\Client;
  9. use App\Http\Controllers\Controller;
  10. use App\Http\Requests\Request;
  11. use App\Http\Services\Frontend\Client\Coach\UserService;
  12. use App\Models\Coach\User;
  13. use Illuminate\Http\JsonResponse;
  14. class CoachController extends Controller
  15. {
  16. protected UserService $userService;
  17. public function __construct(UserService $userService)
  18. {
  19. $this->userService = $userService;
  20. }
  21. public function index(): JsonResponse
  22. {
  23. // $this->userService->getUserPage();
  24. $where = ['status' => 1];
  25. $userPage = User::query()->where($where)->paginate();
  26. return self::success(['list' => $userPage->items(), 'total' => $userPage->total()]);
  27. }
  28. public function show()
  29. {
  30. }
  31. /**
  32. * Method : 申请技师
  33. */
  34. public function create(Request $request): JsonResponse
  35. {
  36. $params = $request->only(['name', 'sex', 'birthday', 'mobile', 'city', 'work_img']);
  37. // 验证码验证手机号
  38. $user_id = 1;
  39. if (isset($user_id) && filled($user_id)) {
  40. // 判断技师资格是否已申请
  41. $isExists = User::query()->where('user_id', $user_id)->exists();
  42. if ($isExists) return ['code' => 500, 'msg' => '用户已经申请'];
  43. }
  44. $params['user_id'] = $user_id;
  45. // 判断邀请人$input['partner_id']
  46. $id = User::query()->create($params)->id;
  47. return self::success($id);
  48. }
  49. public function update()
  50. {
  51. }
  52. public function reapply()
  53. {
  54. }
  55. }