Created
May 6, 2018 12:19
-
-
Save raymond1988/510c2a344c26a6f0bfb8fdf7fcc7bcac to your computer and use it in GitHub Desktop.
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
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