/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($slug, Category $category, CategoryUpdate $request)
 {
     /* Edit the selected category via id */
     $category = $category->where('id', $slug)->first();
     $sl = $request->input('slug');
     $slug = str_slug($sl, "-");
     // dd($slug);
     $category->slug = $slug;
     /* update the values at the table via model according with the request */
     if ($category->fill($request->all())->save()) {
         $category->slug = $slug;
         $category->save();
         return redirect('category')->with('success', 'Category Updated Successfully');
     } else {
         return redirect('category')->with('fails', 'Category Not Updated');
     }
 }
 /**
  * Update the specified Category in storage.
  * @param type $slug 
  * @param type Category $category 
  * @param type CategoryUpdate $request 
  * @return type redirect
  */
 public function update($slug, Category $category, CategoryUpdate $request)
 {
     /* Edit the selected category via id */
     $category = $category->where('id', $slug)->first();
     $sl = $request->input('slug');
     $slug = str_slug($sl, "-");
     // dd($slug);
     $category->slug = $slug;
     /* update the values at the table via model according with the request */
     //redirct to index page with success message
     try {
         $category->fill($request->all())->save();
         $category->slug = $slug;
         $category->save();
         return redirect('category')->with('success', 'Category Updated Successfully');
     } catch (Exception $e) {
         //redirect to index with fails message
         return redirect('category')->with('fails', 'Category Not Updated' . '<li>' . $e->errorInfo[2] . '</li>');
     }
 }