예제 #1
0
 public function store(Requests\PostStoreRequest $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->url = $request->url;
     $post->body = $request->body;
     if ($request->published_at != "") {
         $time = new Carbon($request->published_at);
         $post->published_at = $time->toDateTimeString();
     } else {
         $post->published_at = null;
     }
     $post->save();
     return redirect('/back/posts')->with('status', 'Created Post');
 }
예제 #2
0
 public function index()
 {
     $posts = Post::where('published_at', '<=', Carbon::now())->orderBy('published_at')->paginate(2);
     return view('front/blog', compact('posts'));
 }