Last active
February 13, 2018 18:21
-
-
Save anthonyterrell/3fdc4e368becb887259fd692d88d87f2 to your computer and use it in GitHub Desktop.
Blog post controller for Laravel Model Observer piece.
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
/** | |
* Store a newly created resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
$post = new BlogPost($request->all()); | |
$post->generateSlug(); // generate a url friendly slug of the article | |
$post->save(); | |
$post->publish(); // some logic to officially publish the article | |
// return response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment