PaintController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Http\Controllers\Deed;
  3. use App\Http\Controllers\Core\Auth;
  4. use App\Models\Deed\PaintModel;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7. class PaintController extends Controller
  8. {
  9. //
  10. public function index(Request $request)
  11. {
  12. }
  13. /**
  14. * 创建绘画
  15. * @param Request $request
  16. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  17. */
  18. public function store(Request $request)
  19. {
  20. $this->validate($request, [
  21. 'name' => 'required|max:8',
  22. 'pic_url' => 'required|url',
  23. 'actions' => 'required',
  24. ]);
  25. $uid = Auth::auth();
  26. $paint = PaintModel::create($request->merge(['uid' => $uid])->all());
  27. return response([
  28. 'code' => 200,
  29. 'message' => 'OK',
  30. 'data' => $paint
  31. ]);
  32. }
  33. /**
  34. * 查看指定绘画
  35. * @param $id
  36. * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  37. */
  38. public function show($id)
  39. {
  40. $paint = PaintModel::findOrFail($id);
  41. $paint->user;
  42. return response([
  43. 'code' => 200,
  44. 'message' => 'OK',
  45. 'data' => $paint
  46. ]);
  47. }
  48. }