/** * Store new model and redirect * * @param WhaleRequest $request data from form * * @return main page * */ public function store(WhaleRequest $request) { $whale = Whale::create($request->except('food_list')); $foodsId = $request->input('food_list', []); $whale->foods()->attach($foodsId); Session::flash('flash_message', 'New whale has been added!'); return redirect('whale'); }
/** * Store new model and redirect * * @param WhaleRequest $request data from form * * @return main page * */ public function store(WhaleRequest $request) { Whale::create($request->all()); \Session::flash('flash_message', 'New whale has been added!'); return redirect('whale'); }