简体   繁体   English

是否有用于使用多个 guarda 记录但使用单个 api 的特定模式

[英]Is there a specific pattern for logging with multiple guarda but with single api

In a Laravel project,there are five users with different 5 guards,在一个 Laravel 的项目中,有五个用户,有不同的 5 个守卫,

I want to create a single function for login for all these users.我想为所有这些用户创建一个 function 用于登录。

Is there any a specific way to do that instead of if..elseif..else?有什么特定的方法可以代替 if..elseif..else 吗?

You have five guards, so you have five different models also你有五个守卫,所以你也有五个不同的模型

so if you want to perform login with single controller's function then you have to pass user type of for filtration.所以如果你想使用单个控制器的 function 执行登录,那么你必须通过用户类型进行过滤。

Because when you pass credentials to login function with multiple guards, then you have to specify user type for filtration of models because after that we can identify on which model we have to check credentials因为当您将凭据传递给多个守卫登录 function 时,您必须指定用户类型以过滤模型,因为之后我们可以确定我们必须检查哪个 model 凭据

And if you have more guards then you can use Switch case also如果你有更多的警卫,那么你也可以使用 Switch case

Maybe it will helpful也许会有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM