Skip to content

Instantly share code, notes, and snippets.

@ferdiunal
Last active October 11, 2016 19:02
Show Gist options
  • Save ferdiunal/bfb9154eb5a2677f4f54d4559d4c41b5 to your computer and use it in GitHub Desktop.
Save ferdiunal/bfb9154eb5a2677f4f54d4559d4c41b5 to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use App\Page;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
Route::bind('article_date',function($value,$route){
$parms = $route->parameters();
$pages = Page::find($parms['id']);
if(isset($pages)) { return $pages; }
return abort(404);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment