Reputation: 1126
How do I actually pass model to a filter?
I have a form that allows user with enough privilege to edit and save a book.
Route::model('book', 'Book');
Route::get('/edit/{book}', array('before' => 'my_filter', 'uses' => 'BookController@showForm'));
Route::filter('my_filter', function() {
// check if authenticated has enough privilege to edit a book
// Would like to do something like $book->AuthorID == Auth()::user()->AuthorID
});
Any suggestion? Thanks!
Upvotes: 0
Views: 26
Reputation: 12101
Route::filter('my_filter', function($route) {
$book = $route->getParameter('book');
if( $book->AuthorID == Auth()::user()->AuthorID){
// .......
}
});
Upvotes: 1