app/Http/Controllers/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)
    {
        $category = Category::find($id);
        $this->validate($request,[
            'name' => 'required|max:255',
            'user_id' => 'required'
        ]);
        $category->name = $request->name;
        $category->user_id = $request->user_id;
        $category->slug = str_slug($request->name);
        $category->save();
        Session::flash('success','You have update category succesfully');
        return redirect()->route('category.index');
    }
public function update ( Request $ request , $ id ) { $ category = Category :: find ( $ id ) ; $ this -> validate ( $ request , [ 'name' => 'required|max:255' , 'user_id' => 'required' ] ) ; $ category -> name = $ request -> name ; $ category -> user_id = $ request -> user_id ; $ category -> slug = str_slug ( $ request -> name ) ; $ category -> save ( ) ; Session :: flash ( 'success' , 'You have update category succesfully' ) ; return redirect ( ) -> route ( 'category.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .