CommendController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use Illuminate\Http\Request;
  4. use App\Facades\MentalityDrillFacade;
  5. use App\Facades\ScaleFacade;
  6. use App\Facades\SpecialistInfoFacade;
  7. class CommendController extends BaseController
  8. {
  9. /**
  10. * Display a listing of the resource.
  11. *
  12. * @return \Illuminate\Http\Response
  13. */
  14. public function index()
  15. {
  16. $commentTag = request('comment_tag');
  17. if ($commentTag){
  18. $commentTag = explode(',', $commentTag);
  19. }
  20. $conditions = [
  21. 'comment_tag' => $commentTag
  22. ];
  23. $fields = ['*'];
  24. $page = request('page', 1);
  25. $limit = request('limit', 20);
  26. switch (request('type')){
  27. case 1: //训练
  28. $sort = '`number_of_studies` desc, `id` desc';
  29. return MentalityDrillFacade::getList($conditions, $fields, $sort, $page, $limit);
  30. break;
  31. case 2: //量表
  32. $sort = '`number_of_test` desc, `id` desc';
  33. return ScaleFacade::getList($conditions, $fields, $sort, $page, $limit);
  34. break;
  35. case 3: //文章(专家来了)
  36. $sort = '`number_of_studies` desc, `id` desc';
  37. return SpecialistInfoFacade::getList($conditions, $fields, $sort, $page, $limit);
  38. break;
  39. }
  40. }
  41. /**
  42. * Store a newly created resource in storage.
  43. *
  44. * @param \Illuminate\Http\Request $request
  45. * @return \Illuminate\Http\Response
  46. */
  47. public function store(Request $request)
  48. {
  49. //
  50. }
  51. /**
  52. * Display the specified resource.
  53. *
  54. * @param int $id
  55. * @return \Illuminate\Http\Response
  56. */
  57. public function show($id)
  58. {
  59. //
  60. }
  61. /**
  62. * Update the specified resource in storage.
  63. *
  64. * @param \Illuminate\Http\Request $request
  65. * @param int $id
  66. * @return \Illuminate\Http\Response
  67. */
  68. public function update(Request $request, $id)
  69. {
  70. //
  71. }
  72. /**
  73. * Remove the specified resource from storage.
  74. *
  75. * @param int $id
  76. * @return \Illuminate\Http\Response
  77. */
  78. public function destroy($id)
  79. {
  80. //
  81. }
  82. }