Created
November 7, 2017 17:45
-
-
Save rfmeier/b848440a7af6c88c1e4992c74007eb2e to your computer and use it in GitHub Desktop.
Simple controller model update in Laravel.
This file contains hidden or 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 | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \App\Product $product | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function update(Request $request, Product $product) | |
{ | |
$this->validate($request, [ | |
'name' => 'required|max:255', | |
'price' => 'required|numeric', | |
]); | |
$product->update( | |
$request->only('name', 'price') | |
); | |
return back()->with('status', 'The product was updated!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment