<?php namespace Orchestra\Story\Routing;

use Illuminate\Routing\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Orchestra\Story\Model\Content;

class HomeController extends Controller {

	/**
	 * Get landing page.
	 *
	 * @access public
	 * @return Response
	 */
	public function index()
	{
		$page = Config::get('orchestra/story::default_page', '_posts_');

		if ($page === '_posts_') return $this->showPosts();

		return $this->showDefaultPage($page);
	}

	/**
	 * Show posts.
	 *
	 * @access public
	 * @return Response
	 */
	public function showPosts()
	{
		$posts = Content::post()->publish()->paginate(10);

		return View::make('orchestra/story::posts', compact('posts'));
	}

	/**
	 * Show default page.
	 * 
	 * @access protected
	 * @param  string   $slug
	 * @return Response
	 */
	protected function showDefaultPage($slug)
	{
		$page = Content::page()->publish()->where('slug', '=', $slug)->firstOrFail();
		
		if ( ! View::exists($view = "orchestra/story::pages.{$slug}"))
		{
			$view = 'orchestra/story::page';
		}

		return View::make($view, compact('page'));
	}
}

<?php namespace Orchestra\Story\Routing;

use Illuminate\Routing\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Orchestra\Story\Model\Content;

class HomeController extends Controller {

	/**
	 * Get landing page.
	 *
	 * @access public
	 * @return Response
	 */
	public function index()
	{
		$page = Config::get('orchestra/story::default_page', '_posts_');

		if ($page === '_posts_') return $this->showPosts();

		return $this->showDefaultPage($page);
	}

	/**
	 * Show posts.
	 *
	 * @access public
	 * @return Response
	 */
	public function showPosts()
	{
		$posts = Content::post()->publish()->paginate(Config::get('orchestra/story::per_page', 10));

		return View::make('orchestra/story::posts', compact('posts'));
	}

	/**
	 * Show default page.
	 * 
	 * @access protected
	 * @param  string   $slug
	 * @return Response
	 */
	protected function showDefaultPage($slug)
	{
		$page = Content::page()->publish()->where('slug', '=', $slug)->firstOrFail();
		
		if ( ! View::exists($view = "orchestra/story::pages.{$slug}"))
		{
			$view = 'orchestra/story::page';
		}

		return View::make($view, compact('page'));
	}
}

Load pagination per_page limit from configuration.
Load pagination per_page limit from configuration.

Signed-off-by: crynobone <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>
