app/Http/Controllers/BlogController.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(UpdateBlogRequest $request, Blog $blog)
    {
        $fields = $request->validated();
        $blog->update($fields);
        if ($request->hasFile('img')) {
            $photo_path = $request->file('img')->store('public/blog');
            $blog->img = basename($photo_path);
        }
        $blog->save();
        return redirect()->route('blog.index')
            ->with('success', 'Post was updated successfully', compact('blog'));
    }
public function update ( UpdateBlogRequest $ request , Blog $ blog ) { $ fields = $ request -> validated ( ) ; $ blog -> update ( $ fields ) ; if ( $ request -> hasFile ( 'img' ) ) { $ photo_path = $ request -> file ( 'img' ) -> store ( 'public/blog' ) ; $ blog -> img = basename ( $ photo_path ) ; } $ blog -> save ( ) ; return redirect ( ) -> route ( 'blog.index' ) -> with ( 'success' , 'Post was updated successfully' , compact ( 'blog' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .