/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateCategoryRequest $request, $id)
 {
     $data = ['name' => $request->input('name', ''), 'description' => $request->input('description', '')];
     $category = Category::find($id);
     foreach ($data as $key => $value) {
         if ($value != '') {
             $category->{$key} = $value;
         }
     }
     if ($request->file('image') != null) {
         $category->image = $this->file_service->upload($request->file('image'), 'category');
     }
     $father_id = $request->input('father_id', '');
     if ($category->father_id) {
         $category->type = 2;
         $category->father_id = $father_id;
     }
     $category->save();
     return redirect()->route('admin.categories.index');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateCategoryRequest $request, $id)
 {
     $category = $this->dispatch(new UpdateCategory($id, app('user'), $request->only(['name'])));
     return $this->setStatus(200)->setMessage('success on update')->respond($category);
 }