Laravel - 将元数据保存为多对多关系

I want to save a recipe like this:

                $recipe = new Recipe;
            //$recipe->user_id = Auth::user()->id;
            $recipe->user_id = 40;
            $recipe->title = Input::get('title');
            $recipe->short_desc = Input::get('short_desc');
            $recipe->prep_time = Input::get('prep_time');
            $recipe->status = 0;
            $recipe->amount = Input::get('amount');
            $recipe->save();
            //$recipe->ingredients()->sync(Input::get('ingredients'));
            foreach(Input::get('ingredients') as $key => $ingredient) {
                $recipe->ingredients()->attach($key,['unit' => $ingredient['unit'], 'amount' => $ingredient['amount']]);
            }
            //$recipe->ingredients()->attach($ingredients->id,['unit' => $unit, 'amount' => $amount]);
            $recipe->categories()->sync(Input::get('categories'));
            $recipe->recipesteps()->sync(Input::get('description'));

            $recipe->push();
        //}
        return json_encode($recipe);  

Data I input via POSTMAN:
http://monosnap.com/image/K5e44iPt3SRaeNhxZqwduXBfIyOeD9

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unit' in 'field list' (SQL: insert into `rezepte_ingredients_recipe` (`amount`, `ingredients_id`, `recipe_id`, `unit`) values (100, 0, 13, gr))  

So it seems that my foreach doesn't create the "ingredients", it just wants to add them.

How can I create the Ingredient(in the ingredients table) with "ID and "name" and add the meta data to the pivot table (unit and amount) ?

Thanks!

Got it!

             foreach(Input::get('ingredients') as $key => $i) {
                $ingredient = new Ingredients(array('name' => $i['name'],'unit' => $i['unit']));
                $ingredient->save();
                $recipe->ingredients()->attach($ingredient->id,['amount' => $i['amount']]);
            }  

->save() was missing!