/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $input = $request->all(); $pizza = Pizza::create($input); $pizza->ingredients()->attach($input['ingredients']); return redirect('pizzas'); }
/** * Delete pizza * * @param Request $request * @param Pizza $pizza * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @throws \Exception */ public function destroy(Request $request, Pizza $pizza) { $pizza->delete(); return redirect('/pizza'); }
/** * Run the database seeds. * * @return void */ public function run() { Pizza::create(['ime' => 'Capriciossa']); Pizza::create(['ime' => 'Venezia']); Pizza::create(['ime' => 'Margarita']); }