Skip to content

Instantly share code, notes, and snippets.

@raymond1988
Created May 6, 2018 12:19
Show Gist options
  • Save raymond1988/510c2a344c26a6f0bfb8fdf7fcc7bcac to your computer and use it in GitHub Desktop.
Save raymond1988/510c2a344c26a6f0bfb8fdf7fcc7bcac to your computer and use it in GitHub Desktop.
public function store(StoreBlogPostRequest $request) {//type hint the store function
//check if the user it authenticated
if (Auth::check()) {
//create a new post
$post = new Post;
//save the post
$post->title = title_case($request->title);
$post->description = $request->description;
$post->content = $request->content;
$post->user_id = $author->id;
$post->author_name = $user_name;
$post->save();
Session::flash('success', 'New post created.');
return redirect()->route('welcome');
} else {
return view('login');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment