Php 检查是否正在调用路由参数

Php 检查是否正在调用路由参数,php,routing,laravel,laravel-4,ioc-container,Php,Routing,Laravel,Laravel 4,Ioc Container,在路由筛选器中,我试图确定是否调用了路由参数,它可能为NULL,但我仍然需要知道是否调用了它 e、 g 所以我解决了自己的问题,我不确定这是传统的还是优雅的方式: in_array('job', $route->getParameterKeys()) 此检查是否已在当前路由上调用路由参数“job”。非常有用 我以前的代码现在看起来像: if( in_array('job', $route->getParameterKeys()) ) { if( is_null($job

在路由筛选器中,我试图确定是否调用了路由参数,它可能为NULL,但我仍然需要知道是否调用了它

e、 g


所以我解决了自己的问题,我不确定这是传统的还是优雅的方式:

in_array('job', $route->getParameterKeys())
此检查是否已在当前路由上调用路由参数“job”。非常有用

我以前的代码现在看起来像:

if( in_array('job', $route->getParameterKeys()) ) {

    if( is_null($job = $route->getParameter('job')) ) {

        return App::abort(404, 'This job does not exist.'); // Show the not found page
    }
    elseif( $job->agency->id != $agency->id ) {

        return App::abort(403, 'You are not authorized to view this job.'); // Show the insufficient permissions page
    }   
}

“路线参数”是什么意思?这是URL参数吗?路由的参数,如应用于该路由的变量中的参数。。。AKA Route::post({agency}/job/view/{job}',Controllers\agency\JobController@postEdit');
if( in_array('job', $route->getParameterKeys()) ) {

    if( is_null($job = $route->getParameter('job')) ) {

        return App::abort(404, 'This job does not exist.'); // Show the not found page
    }
    elseif( $job->agency->id != $agency->id ) {

        return App::abort(403, 'You are not authorized to view this job.'); // Show the insufficient permissions page
    }   
}