SleepController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Http\Controllers\Api\V1\Mentality;
  3. use Illuminate\Http\Request;
  4. use App\Facades\DiarySleepFacade;
  5. use App\Http\Controllers\Api\V1\BaseController;
  6. use Carbon\Carbon;
  7. class SleepController extends BaseController
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return \Illuminate\Http\Response
  13. */
  14. public function index()
  15. {
  16. $conditions = [
  17. 'uid' => $this->auth()
  18. ];
  19. $fields = ['*'];
  20. $sort = '`id` desc';
  21. $page = request('page', 1);
  22. $limit = request('limit', 20);
  23. return DiarySleepFacade::getList($conditions, $fields, $sort, $page, $limit);
  24. }
  25. /**
  26. * Store a newly created resource in storage.
  27. *
  28. * @param \Illuminate\Http\Request $request
  29. * @return \Illuminate\Http\Response
  30. */
  31. public function store(Request $request)
  32. {
  33. $data = $request->all();
  34. $data['uid'] = $this->auth();
  35. $data['day'] = Carbon::today()->toDateString();
  36. $data['repeat'] = 'day:'.$data['day'].' uid:'.$data['uid'];
  37. return DiarySleepFacade::create($data);
  38. }
  39. /**
  40. * Display the specified resource.
  41. *
  42. * @param int $id
  43. * @return \Illuminate\Http\Response
  44. */
  45. public function show($id)
  46. {
  47. //
  48. }
  49. /**
  50. * Update the specified resource in storage.
  51. *
  52. * @param \Illuminate\Http\Request $request
  53. * @param int $id
  54. * @return \Illuminate\Http\Response
  55. */
  56. public function update(Request $request, $id)
  57. {
  58. //
  59. }
  60. /**
  61. * Remove the specified resource from storage.
  62. *
  63. * @param int $id
  64. * @return \Illuminate\Http\Response
  65. */
  66. public function destroy($id)
  67. {
  68. //
  69. }
  70. }