/** * Run the database seeds. * * @return void */ public function run() { DB::table('ingredients')->delete(); Ingredient::create(array('Name' => 'Flour', 'MeasurementType' => 'cups')); Ingredient::create(array('Name' => 'Butter', 'MeasurementType' => 'tablespoon')); Ingredient::create(array('Name' => 'Baking Powder', 'MeasurementType' => 'teaspoons')); Ingredient::create(array('Name' => 'Eggs', 'MeasurementType' => 'ea')); Ingredient::create(array('Name' => 'Oil', 'MeasurementType' => 'tablespoons')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Store $request) { $ingredient = Ingredient::create($request->only('name')); if ($request->file('imagePath')) { $cropSize = $request->get('cropSize'); $img = Image::make($request->file('imagePath')->getRealPath()); $img_name = str_random(15) . '.jpg'; $img->fit(500)->save('img/ingredients/' . $img_name); $ingredient->imagePath = $img_name; } else { $ingredient->imagePath = 'default.jpg'; } foreach ($request->only('tags') as $tag) { $ingredient->tags()->attach($tag); } $ingredient->save(); return redirect()->route('ingredient.index'); }
public function processInsertIngredient(Request $request) { $newIngredientInsert = \App\Ingredient::create(['name' => $request->newingr['name'], 'type' => $request->newingr['type']]); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { Ingredient::create($request->all()); return redirect('ingredients'); }
public function store(Request $request) { $this->validate($request, ['description' => 'required', 'type_id' => 'required']); Ingredient::create(['description' => $request->input('description'), 'type_id' => $request->input('type_id')]); return Redirect::to('ingredients'); }