Skip to content

Instantly share code, notes, and snippets.

@weotch
Forked from anonymous/gist.php
Last active February 23, 2016 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weotch/d7d7767236492732b2a4 to your computer and use it in GitHub Desktop.
Save weotch/d7d7767236492732b2a4 to your computer and use it in GitHub Desktop.
<?php
Route::get('guidelines/{slug}/{page}', ['as' => 'guideline-page', function($slug, $page) {
$guideline = Guideline::findBySlugOrFail($slug);
$page = $guideline->guidelineBlocks()->where('slug', $page)->firstOrFail();
// previous pages
$previous = $guideline->guidelineBlocks()
->where('guideline_blocks.position', '<', $page->position)
->orderBy('guideline_blocks.position', 'desc')
->first();
$next = $guideline->guidelineBlocks()
->where('guideline_blocks.position', '>', $page->position)
->orderBy('guideline_blocks.position', 'asc')
->first();
echo $previous->title;
//print_r($previous);
die;
return layout('coma.guideline-page', [
'guideline' => $guideline,
'page' => $page,
]);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment