public function testDestroy()
 {
     $series = factory(Series::class)->create();
     $this->action('DELETE', 'Admin\\SeriesController@destroy', $series);
     $this->assertRedirectedToRoute('admin.series.index');
     $this->assertEquals(0, Series::count());
 }
 /**
  * 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');
 }
 /**
  * Get the series.
  *
  * @param  int  $limit
  * @return void
  */
 protected function getSeries($limit = null)
 {
     $series = Series::whereHas('posts', function ($query) {
         $query->published();
     })->take($limit)->get();
     foreach ($series as $singleSeries) {
         Sitemap::addTag(route('series.show', $singleSeries), $singleSeries, 'weekly', '0.8');
     }
 }
 /**
  * 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');
 }
 /**
  * DELETE /admin/series/series-slug
  * Remove a series from storage.
  *
  * @param  \NeonTsunami\Series  $series
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy(Series $series)
 {
     $series->delete();
     return redirect()->route('admin.series.index')->withSuccess('The series was deleted.');
 }
 /**
  * GET /series/series-slug
  * Get a single series.
  *
  * @param  \NeonTsunami\Series  $series
  * @return \Illuminate\View\View
  */
 public function show(Series $series)
 {
     $posts = $series->posts()->published()->paginate();
     return view('series.show', compact('series', 'posts'))->withTitle($series->name)->withDescription(str_limit($series->description, 160));
 }
 /**
  * GET /admin/posts/post-slug/edit
  * Display the form for editing a post.
  *
  * @param  \NeonTsuanmi\Post  $post
  * @return \Illuminate\View\View
  */
 public function edit(Post $post)
 {
     $series = [null => 'Select...'] + Series::lists('name', 'id')->all();
     return view('admin.posts.edit', compact('post', 'series'))->withTitle('Edit post');
 }