app/Http/Controllers/Admin/PostController.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)
    {
        $request->validate([
            'title'=>'required',
            'content'=>'required',
        ]);
        $post = Post::find($id);
        $post->title =  $request->title;
        $post->content =  $request->content;
        $post->updated_at = now();
        $post->save();
        return redirect()->route('post')->with('success','Chỉnh sửa bài thành công!');
    }
public function update ( Request $ request , $ id ) { $ request -> validate ( [ 'title' => 'required' , 'content' => 'required' , ] ) ; $ post = Post :: find ( $ id ) ; $ post -> title = $ request -> title ; $ post -> content = $ request -> content ; $ post -> updated_at = now ( ) ; $ post -> save ( ) ; return redirect ( ) -> route ( 'post' ) -> with ( 'success' , 'Chỉnh sửa bài thành công!'); }
Update the specified resource in storage.
Update the specified resource in storage .