So, let's say I have a simple controller that processes books.
App\Http\Controllers\SimpleBooksController
Inside routes.phpI will register a route for him:
Route::get('books/{id}','SimpleBooksController@doSimpleStuff');
But the world of books is not so simple. Therefore, I would like to have another controller that handles the really complex material of the book.
In my head, I suppose something like this would be really helpful:
class ComplexBooksController extends SimpleBooksController
In this way, routes that are not explicitly handled by the child class are returned to the parent class.
Now let's say each book knows whether it is complicated or not: $book->isComplex
And I would like to do something like this
if (!$book->isComplex) {
// route 'books/{id}' to SimpleBooksController@doSimpleStuff
} else {
// route 'books/{id}' to ComplexBooksController@doComplexStuff
}
So how can this be done?
* edit *
The way I'm handling this right now is to install the controllers in route.php statically, but let them listen to parameterized routes:
Route::get('books/simple/{id}', 'SimpleBooksController@doSimpleStuff');
Route::get('books/complex/{id}', 'ComplexBooksController@doComplexStuff');