php get参数过滤器,php – 将参数传递给过滤器 – Laravel 4

是否可以访问过滤器内的路由参数?

例如我想访问$ agencyId参数:

Route::group(array('prefix' => 'agency'), function()

{

# Agency Dashboard

Route::get('{agencyId}', array('as' => 'agency', 'uses' => 'Controllers\Agency\DashboardController@getIndex'));

});

我想访问我的过滤器中的$ agencyId参数:

Route::filter('agency-auth', function()

{

// Check if the user is logged in

if ( ! Sentry::check())

{

// Store the current uri in the session

Session::put('loginRedirect', Request::url());

// Redirect to the login page

return Redirect::route('signin');

}

// this clearly does not work..? how do i do this?

$agencyId = Input::get('agencyId');

$agency = Sentry::getGroupProvider()->findById($agencyId);

// Check if the user has access to the admin page

if ( ! Sentry::getUser()->inGroup($agency))

{

// Show the insufficient permissions page

return App::abort(403);

}

});

仅供参考,我将控制器中的此过滤器称为:

class AgencyController extends AuthorizedController {

/**

* Initializer.

*

* @return void

*/

public function __construct()

{

// Apply the admin auth filter

$this->beforeFilter('agency-auth');

}

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值