UserMilestoneController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. class UserMilestoneController extends Controller
  5. {
  6. /**
  7. * Display a listing of the resource.
  8. *
  9. * @return \Illuminate\Http\Response
  10. */
  11. public function index()
  12. {
  13. //
  14. }
  15. /**
  16. * Store a newly created resource in storage.
  17. *
  18. * @param \Illuminate\Http\Request $request
  19. * @return \Illuminate\Http\Response
  20. */
  21. public function store(Request $request)
  22. {
  23. //
  24. }
  25. /**
  26. * Display the specified resource.
  27. *
  28. * @param int $id
  29. * @return \Illuminate\Http\Response
  30. */
  31. public function show($studioName)
  32. {
  33. //
  34. $user_uid = StudioApi::getIdByName($studioName);
  35. $milestone = [];
  36. $milestone[] = ['date'=>UserInfo::where('userid',$user_uid)->value('created_at'),'event'=>'sign-in'] ;
  37. if(Wbw::where('creator_uid',$user_uid)->exists()){
  38. $milestone[] = ['date'=>Wbw::where('creator_uid',$user_uid)
  39. ->orderBy('created_at')
  40. ->value('created_at'),
  41. 'event'=>'first-wbw'
  42. ] ;
  43. }
  44. if(Sentence::where('editor_uid',$user_uid)->exists()){
  45. $milestone[] = ['date'=>Sentence::where('editor_uid',$user_uid)
  46. ->orderBy('created_at')
  47. ->value('created_at'),
  48. 'event'=>'first-translation'
  49. ] ;
  50. }
  51. if(DhammaTerm::where('owner',$user_uid)->exists()){
  52. $milestone[] = ['date'=>DhammaTerm::where('owner',$user_uid)
  53. ->orderBy('created_at')
  54. ->value('created_at'),
  55. 'event'=>'first-term'
  56. ] ;
  57. }
  58. if(Course::where('studio_id',$user_uid)->exists()){
  59. $milestone[] = ['date'=>Course::where('studio_id',$user_uid)
  60. ->orderBy('created_at')
  61. ->value('created_at'),
  62. 'event'=>'first-course'
  63. ] ;
  64. }
  65. return $this->ok($milestone);
  66. }
  67. /**
  68. * Update the specified resource in storage.
  69. *
  70. * @param \Illuminate\Http\Request $request
  71. * @param int $id
  72. * @return \Illuminate\Http\Response
  73. */
  74. public function update(Request $request, $id)
  75. {
  76. //
  77. }
  78. /**
  79. * Remove the specified resource from storage.
  80. *
  81. * @param int $id
  82. * @return \Illuminate\Http\Response
  83. */
  84. public function destroy($id)
  85. {
  86. //
  87. }
  88. }