Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 具有参数的路由的Laravel控制器请求数组为空_Php_Jquery_Laravel_Seo - Fatal编程技术网

Php 具有参数的路由的Laravel控制器请求数组为空

Php 具有参数的路由的Laravel控制器请求数组为空,php,jquery,laravel,seo,Php,Jquery,Laravel,Seo,我想有一个搜索引擎优化友好的网址,为此,我做了一个jquery函数,我访问的网页。就像blade.php中提到的那样 参数已成功传递到url中,但我没有在控制器端接收到它。并显示为空或null index.blade.php var v_href = "http://mywebsite.com/program/course/"+discipline+"/"+city+"/"+discipline_id+"/"

我想有一个搜索引擎优化友好的网址,为此,我做了一个jquery函数,我访问的网页。就像blade.php中提到的那样

参数已成功传递到url中,但我没有在控制器端接收到它。并显示为空或null

index.blade.php

var v_href      = "http://mywebsite.com/program/course/"+discipline+"/"+city+"/"+discipline_id+"/"+city_id;
v_href          = v_href.replace('--', '-');
window.location.href = v_href;

路由文件

web.php

Route::get('/program/course/{discipline?}/{city?}/{discipline_id?}/{city_id?}', 'FinderController@index')->name('finder.index');
控制器功能


            $discipline_id  = $request->input('discipline_id');
            $city_id        = $request->input('city_id');


但是我在两个变量中都得到了null

要检索路由参数,必须将它们作为参数添加到控制器函数中。因此,在您的例子中,假设函数名为
getSource()
,您可以这样做:

public function getSource(?string $discipline = null, ?string $city = null, ?int $discipline_id = null, ?int $city_id = null)
{
    dd($discipline, $city, $discipline_id, $city_id);
}

为您提供
NULL
值的URL到底是什么?对于所有URL,无法获取任何数据似乎$request是空的。另外还有另一个参数,如$request->except('page'),用于分页,其不同,这是一个查询参数,您应该通过
$request
变量获得它,它与
公共函数索引一起工作(request$request,string$procility=null,string$city=null,int$procility\u id=null,int$city\u id=null){
谢谢:)