app/Http/Controllers/Api/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(BlogRequest $request, $id)
    {
        if (!$id) {
            throw new HttpException(400, "Invalid id");
        }
        try {
           $blog = Blog::find($id);
           $blog->fill($request->validated())->save();
           return new BlogResource($blog);
        } catch(\Exception $exception) {
           throw new HttpException(400, "Invalid data - {$exception->getMessage}");
        }
    }
public function update ( BlogRequest $ request , $ id ) { if ( ! $ id ) { throw new HttpException ( 400 , " Invalid id " ) ; } try { $ blog = Blog :: find ( $ id ) ; $ blog -> fill ( $ request -> validated ( ) ) -> save ( ) ; return new BlogResource ( $ blog ) ; } catch ( \ Exception $ exception ) { throw new HttpException ( 400 , " Invalid data -  { $ exception -> getMessage } " ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .