app/Http/Controllers/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',
            'category_id' => 'required',
            'image' => 'required|image'
        ]);
        $post= Post::find($id);
        $post->title = $request->title;
        $post->content = $request->content;
        $post->category_id = $request->category_id;
        $post->image = $request->file('image')->store('upload');
        $post->save();
        return redirect()->route('post.index');
    }
public function update ( Request $ request , $ id ) { $ request -> validate ( [ 'title' => 'required' , 'content' => 'required' , 'category_id' => 'required' , 'image' => 'required|image' ] ) ; $ post = Post :: find ( $ id ) ; $ post -> title = $ request -> title ; $ post -> content = $ request -> content ; $ post -> category_id = $ request -> category_id ; $ post -> image = $ request -> file ( 'image' ) -> store ( 'upload' ) ; $ post -> save ( ) ; return redirect ( ) -> route ( 'post.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .