SubscribeController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Http\Controllers\Goodnight;
  3. use App\Http\Controllers\Miniprogram\Auth;
  4. use App\Services\Goodnight\SubscribeService;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7. class SubscribeController extends Controller
  8. {
  9. public function subscribe(Request $request)
  10. {
  11. $uid = Auth::auth();
  12. $this->validate($request, [
  13. 'type' => 'required|in:1, 2, 3'
  14. ]);
  15. $type = $request->post('type');
  16. $subService = new SubscribeService();
  17. $subscribed_at = $subService->subscribe($uid, $type);
  18. return array(
  19. 'code' => 200,
  20. 'message' => 'success',
  21. 'data' => [
  22. 'subscribed_at' => $subscribed_at
  23. ]
  24. );
  25. }
  26. public function voices(Request $request)
  27. {
  28. $uid = Auth::auth();
  29. $page = $request->get('page') ?? 1;
  30. $subService = new SubscribeService();
  31. $data = $subService->voices($page, 20, $uid);
  32. return array(
  33. 'code' => 200,
  34. 'message' => 'success',
  35. 'data' => [
  36. 'page' => $page,
  37. 'limit' => 20,
  38. 'total' => $data['total'],
  39. 'list' => $data['list']
  40. ]
  41. );
  42. }
  43. public function fishVoice()
  44. {
  45. $uid = Auth::auth();
  46. $ss = new SubscribeService();
  47. $data = $ss->fishVoice($uid);
  48. return array(
  49. 'code' => 200,
  50. 'message' => 'success',
  51. 'data' => $data
  52. );
  53. }
  54. public function todayVoice()
  55. {
  56. $uid = Auth::auth();
  57. $ss = new SubscribeService();
  58. $data = $ss->todayVoice($uid);
  59. return array(
  60. 'code' => 200,
  61. 'message' => 'success',
  62. 'data' => $data
  63. );
  64. }
  65. }