Skip to content

Instantly share code, notes, and snippets.

@anthonyterrell
Last active February 13, 2018 18:21
Show Gist options
  • Save anthonyterrell/3fdc4e368becb887259fd692d88d87f2 to your computer and use it in GitHub Desktop.
Save anthonyterrell/3fdc4e368becb887259fd692d88d87f2 to your computer and use it in GitHub Desktop.
Blog post controller for Laravel Model Observer piece.
/**
* 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