Laravel控制器如何实现多防护访问方法?

时间:2018-07-11 10:00:10

标签: php laravel

我正在尝试在控制器的构造函数中调用中间件。

我的PostController类在下面

class PostController extends Controller
{
    public function __construct()
    {
        $this->middleware( ['auth:admin', ['only'=> ['store', 'update']]], ['auth:client', ['only'=> ['index', 'view']]]);
    }    
}

如果我错了,请提出建议或纠正我。

2 个答案:

答案 0 :(得分:0)

我认为最好的方法是在路线上

newPtr->data = malloc(strlen(value)+1);
strcpy(newPtr->data, value);

或分组显示,例如:

Dim i As Long 

Dim IE As Object

Dim Doc As Object

Dim objElement As Object

Dim objCollection As Object

Dim buttonCollection As Object

Dim valeur_heure As Object


' Create InternetExplorer Object

Set IE = CreateObject("InternetExplorer.Application")

' You can uncoment Next line To see form results

IE.Visible = True

' Send the form data To URL As POST binary request

IE.Navigate "http://Mysite/Home/"

Dim elements As Object, element As Object

For Each element In IE.Document.getElementsByTagName("img")

    If element.innertext = "r/std/icons/combi64.png" Then
         element.Focus
        element.Click
        Exit For
    End If

Next

  Set IE = Nothing

答案 1 :(得分:0)

是的,您可以多次调用中间件功能。

class PostController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth:admin', ['only'=> ['store', 'update']])
        $this->middleware('auth:client', ['only'=> ['index', 'view']]);
    }

}