/**
  * Get the latest published posts.
  *
  * @param  int  $limit
  * @return void
  */
 protected function getPosts($limit = null)
 {
     $posts = Post::published()->latest()->take($limit)->get();
     foreach ($posts as $post) {
         Sitemap::addTag(route('posts.show', $post), $post, 'daily', '0.9');
     }
 }
 public function testDestroy()
 {
     $post = factory(Post::class)->create();
     $this->action('DELETE', 'Admin\\PostsController@destroy', $post);
     $this->assertRedirectedToRoute('admin.posts.index');
     $this->assertEquals(0, Post::count());
 }
 /**
  * GET /rss
  * Return the RSS feed of posts.
  *
  * @return \Illuminate\Http\Response
  */
 public function rss()
 {
     $posts = Post::published()->latest()->take(100)->get();
     if ($posts->count()) {
         $updated = $posts->first()->updated_at;
     }
     return response()->view('pages.rss', compact('posts', 'updated'), 200, ['Content-Type' => 'application/rss+xml; charset=UTF-8']);
 }
 /**
  * GET /admin/users
  * Display a listing of users.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $postsCount = Post::count();
     $seriesCount = Series::count();
     $projectsCount = Project::count();
     $usersCount = User::count();
     return view('admin.pages.index', compact('postsCount', 'seriesCount', 'projectsCount', 'usersCount'))->withTitle('Admin');
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('posts', function ($value, $route) {
         return Post::whereSlug($value)->firstOrFail();
     });
     $router->bind('series', function ($value, $route) {
         return Series::whereSlug($value)->firstOrFail();
     });
     $router->bind('tags', function ($value, $route) {
         return Tag::whereSlug($value)->firstOrFail();
     });
     $router->bind('projects', function ($value, $route) {
         return Project::whereSlug($value)->firstOrFail();
     });
     $router->model('users', 'NeonTsunami\\User');
 }
 /**
  * GET /posts/post-slug
  * Get a single post.
  *
  * @param  \NeonTsunami\Post  $post
  * @return \Illuminate\Http\Response
  */
 public function show(Post $post)
 {
     $post->load('series', 'tags', 'user');
     $post->increment('views');
     return view('posts.show', compact('post'))->withTitle($post->title)->withDescription(str_limit($post->content, 160));
 }
 /**
  * DELETE /admin/posts/post-slug
  * Remove a post from storage.
  *
  * @param  \NeonTsunami\Post  $post
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy(Post $post)
 {
     $post->delete();
     return redirect()->route('admin.posts.index')->withSuccess('The post was deleted.');
 }