I would like to know how to combine data from Input::all()with a model and save the result.
Input::all()
To clarify: I would like to do something like below:
$product = Product::find(1); // Eloquent Model $product->merge( Input::all() ); // This is what I am looking for :) $product->save();
You should use the method update:
update
$product->update(Input::all());
But I recommend using the onlymethod instead
only
$product->update(Input::only('name', 'type...'));
In addition to Razor's answer, if you need to create a new model, you can use:
$product = Product::create(Input::all());
fill() . :
fill()
$product->fill($request->all()); $product->foo = 'bar'; $product->save();
$fillable , Input::only(...) ( $request->only(...) ).
$fillable
Input::only(...)
$request->only(...)
Source: https://habr.com/ru/post/1544300/More articles:Problems with correlation graphs in bokeh - pythonWriting a jasmine test specification for a javascript close function - javascriptHow can I convince z / OS scp to transfer binary files? - linuxbootstrap TimePicker plugin: set full hour / minute / second - javascriptChange thread context for another user - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1544301/doctrine-2-can-i-get-a-reference-from-a-repository-instead-of-from-the-entity-manager&usg=ALkJrhhZ0AE1KXlLfFg-Noh8kTbN7wQ8qAonActivityResult returns null data for video capture in Nexus 4 with v4.3 - androidant -how can I return a value from a macrodef? - antRelative pointers in a memory mapped file using C - cHow to add distance from a point as an annotation in GeoDjango - djangoAll Articles