app/Http/Controllers/Admin/CategoryController.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)
    {
        $rule=[
            'name'=>'required|string|min:2|max:50',
            'description'=>'required|string|min:2|max:999',
            'color'=>'required'
        ];
        $this->validate($request, $rule);
        $category=Category::findOrFail($id);
        $category->name=$request->input('name');
        $category->slug=str_slug($request->get('name'));
        $category->description=$request->input('description');
        $category->color=$request->input('color');
        if (!$category->isClean()) {
            $category->save();
        }
        return redirect()->route('home-cate',$id);
    }
public function update ( Request $ request , $ id ) { $ rule = [ 'name' => 'required|string|min:2|max:50' , 'description' => 'required|string|min:2|max:999' , 'color' => 'required' ] ; $ this -> validate ( $ request , $ rule ) ; $ category = Category :: findOrFail ( $ id ) ; $ category -> name = $ request -> input ( 'name' ) ; $ category -> slug = str_slug ( $ request -> get ( 'name' ) ) ; $ category -> description = $ request -> input ( 'description' ) ; $ category -> color = $ request -> input ( 'color' ) ; if ( ! $ category -> isClean ( ) ) { $ category -> save ( ) ; } return redirect ( ) -> route ( 'home-cate' , $ id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .