json([ [ 'id' => 1, 'title' => 'My first post', ], [ 'id' => 2, 'title' => 'New post', ] ]); } public function destroy(int $id): JsonResponse { // мы бы здесь написали вызов запроса delete из БД return response()->json([ 'success' => true, ], Response::HTTP_ACCEPTED); } public function store(Request $request): JsonResponse { return response()->json([ 'title' => $request->get('title'), 'text' => $request->get('text'), ], Response::HTTP_CREATED); } public function update(Request $request, int $id): JsonResponse { return response()->json([ 'title' => $request->get('title'), 'text' => $request->get('text'), ], Response::HTTP_ACCEPTED); } public function show(int $id): JsonResponse { if ($id === 5) { return response()->json( [ 'status' => 'Not found' ], Response::HTTP_NOT_FOUND ); } return response()->json([ 'id' => $id, 'title' => 'My first post', 'text' => 'My first post text', ]); } }