I am looking for a "quick" and "clean" solution to the usual http://project.name/products/total where total is optional.
I've tried so far this:
Route::get('products/{total?}', 'ProductController@get', function ($total = null) {});
And then $products = ($total == null) ? Product::all() : Product::count();
But this not only works with products/total but products/whatever.
I think adding if($total = 'total')
is not a good practice.
I want the last parameter to be static, I am not thinking straight. I guess I have to avoid defining two Routes (Route::get('products'...
and Route::get('products/total'...
Laravel Documentation is not helping either. What am I doing wrong?