app/Http/Controllers/API/CommentController.php
/**
    * Update the specified resource in storage.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  int  $id
    * @return \Illuminate\Http\Response
    */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
  {
    $comment = Comment::findOrFail($id);
    $request->validate([
      'name' => 'required|max:255',
      'email' => 'required'
    ]);
    $comment->name = $request->get('name');
    $comment->email = $request->get('email');
    $comment->save();
    return response()->json($comment);
  }
public function update ( Request $ request , $ id ) { $ comment = Comment :: findOrFail ( $ id ) ; $ request -> validate ( [ 'name' => 'required|max:255' , 'email' => 'required' ] ) ; $ comment -> name = $ request -> get ( 'name' ) ; $ comment -> email = $ request -> get ( 'email' ) ; $ comment -> save ( ) ; return response ( ) -> json ( $ comment ) ; }
Update the specified resource in storage.
Update the specified resource in storage .