Last active
January 30, 2020 16:14
-
-
Save willchambers99/4d7dec90608cbc95b6930f604450f43b to your computer and use it in GitHub Desktop.
Store or update in one function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function crupdate($id = null, Request $request) | |
{ | |
$fields = $request->only(['field_1', 'field_2']); | |
$model = Model::updateOrCreate( | |
[ | |
'id' => $id | |
], | |
$fields | |
); | |
return redirect()->route('your.destination'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment