I have some problems with my controller in laravel 5.4
My routes.php:
Route::group(array('domain' => '{subdomain}.site.com','as'=>'www::','middleware'=>array('web','varnish')), function() {
Route::any('/material/{page?}/', [
'as' => 'www_material', 'uses' => 'www\MaterialController@index'
]);
});
My controller:
<?php namespace App\Http\Controllers\www;
use App\Http\Controllers\Controller;
use View;
use DB;
use Illuminate\Http\Request;
class MaterialController extends Controller {
public function index($subdomain, $page = 1, Request $request)
{
echo $subdomain;
echo $page;
//...some code
}
}
There is no problems with url www.site.com/material/2/:
submodain = www,
page = 2
But www.site.com/material/:
Type error: Too few arguments to function App\Http\Controllers\www\MaterialController::index(), 2 passed and exactly 3 expected
I cant understand why this happend, because default value of page is 1.
Can someone help me? I cant solve this problem alone.
Thank you.