app/Http/Controllers/API/CommentController.php
/**
    * Store a newly created resource in storage.
    *
    * @param  \Illuminate\Http\Request  $request
    * @return \Illuminate\Http\Response
    */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
  {
    $request->validate([
      'name' => 'required|max:255',
      'email' => 'required'
    ]);
    $newComment = new Comment([
      'name' => $request->get('name'),
      'email' => $request->get('email')
    ]);
    $newComment->save();
    return response()->json($newComment);
  }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required|max:255' , 'email' => 'required' ] ) ; $ newComment = new Comment ( [ 'name' => $ request -> get ( 'name' ) , 'email' => $ request -> get ( 'email' ) ] ) ; $ newComment -> save ( ) ; return response ( ) -> json ( $ newComment ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .