app/Http/Controllers/CategoriablogController.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(UpdateCategoriaBlogRequest $request, Category $categories)
    {
        $fields = $request->validated();
        $categories->update($fields);
        if ($request->hasFile('img')) {
            $photo_path = $request->file('img')->store('public/categorias');
            $categories->img = basename($photo_path);
        }
        $categories->save();
        return redirect()->route('categoriasblog.index')
            ->with('success', 'Categoria editada com sucesso', compact('categories'));
    }
public function update ( UpdateCategoriaBlogRequest $ request , Category $ categories ) { $ fields = $ request -> validated ( ) ; $ categories -> update ( $ fields ) ; if ( $ request -> hasFile ( 'img' ) ) { $ photo_path = $ request -> file ( 'img' ) -> store ( 'public/categorias' ) ; $ categories -> img = basename ( $ photo_path ) ; } $ categories -> save ( ) ; return redirect ( ) -> route ( 'categoriasblog.index' ) -> with ( 'success' , 'Categoria editada com sucesso' , compact ( 'categories' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .