Last active
January 30, 2020 16:05
-
-
Save Michael-Stokoe/7d31df97bff5dbe2f5058f450c0636d4 to your computer and use it in GitHub Desktop.
Create/Update method for Laravel.
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