Skip to content

Instantly share code, notes, and snippets.

Created April 25, 2017 10:39
What would you like to do?
Performing a partial update
MyController extends Controller
public function store(Request $request)
$interaction = Interaction::create($this->pick((new Interaction)->getFillable(), $request);
* Get a subset containing the provided keys with values from the input data.
* @param array|mixed $keys
* @param Request $request
* @return array
protected function pick($keys, $request)
$keys = is_array($keys) ? $keys : func_get_args();
return array_intersect_key($request->all(), array_flip($keys));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment