app/Http/Controllers/CategoriesController.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)
    {
        $category = Category::find($id);
        if ($request->hasFile('image')) {
            $file = $request->file('image');
            $extension = $file->getClientOriginalExtension();
            $filename = 'images/categories/' . time() . '.' . $extension;
            $file->move('public/images/categories', $filename);
            $category->image = $filename;
            $update_category = array(
                'image' => $category->image
            );
            $category->update($update_category);
        }
        return redirect('admin/categories');
    }
public function update ( Request $ request , $ id ) { $ category = Category :: find ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ file = $ request -> file ( 'image' ) ; $ extension = $ file -> getClientOriginalExtension ( ) ; $ filename = 'images/categories/' . time ( ) . '.' . $ extension ; $ file -> move ( 'public/images/categories' , $ filename ) ; $ category -> image = $ filename ; $ update_category = array ( 'image' => $ category -> image ) ; $ category -> update ( $ update_category ) ; } return redirect ( 'admin/categories' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .