PatientCardController.php 2.1 KB

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