/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $ingredient = new Ingredient();
     $ingredient->fill($request->all());
     $ingredient->user_id = Auth::id();
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $patch = config('files.ingredients.public_path');
         $name = str_random(25) . '.' . $file->getClientOriginalExtension();
         $image = $patch . $name;
         Image::make($file)->fit(config('files.ingredients.width'), config('files.ingredients.height'))->save($image);
         $ingredient->image = $image;
     }
     $ingredient->save();
     Alert::success('messages.ingredient_created_successfully');
     return redirect()->route('ingredients.edit', $ingredient);
 }
 public function update(Ingredient $ingredient, UpdateIngredientRequest $ingredientRequest)
 {
     $ingredient->fill($ingredientRequest->only('name'))->save();
     $effectIds = $ingredientRequest->has('effects') ? $ingredientRequest->get('effects') : [];
     $ingredient->effects()->sync($effectIds);
 }