使用路由组时调用控制器操作

Call a controller Action when using route group

我想在 laravel blade 中调用一个控制器的动作,当使用路由器组时...

路线

  $router->group([
      'namespace' => 'Admin',
      'middleware' => 'auth',
    ], function () {
        resource('admin/adsense', 'AdsenseController');
        resource('admin/post', 'PostController');
    });

所以,我想在 blade 模板中调用 adsenseController 的操作

{!! Form::model($var, ['method' => 'PATCH','route' => ['what should i write to call an action ']]) !!}

示例(没有路由器组)

路线

Route::resource('subject','SubjectController');

blade 模板

{!! Form::model($var, ['method' => 'PATCH','route' => ['subject.actionName']]) !!}

谢谢

如果你想使用动作,尝试使用这个:

'action' => 'SubjectController@index'

而不是这个:

'route' => ['someroute']

https://laravelcollective.com/docs/5.0/html#opening-a-form

So , i want call an action of adsenseController in the blade template

为什么不直接将表单的操作直接指向控制器?例如

{!! Form::model($var, ['method' => 'PATCH', 'action' => 'Controller@method']) !!}

如果你想重定向到自定义路由,就这么简单

{!! Form::model($var, ['method' => 'PATCH', 'route' => 'route.name']) !!}

查看 documentation on Laravel.com