Php 在laravel中的redirect()助手上添加自定义方法
我想在redirect()助手上添加自定义方法,例如:Php 在laravel中的redirect()助手上添加自定义方法,php,laravel,Php,Laravel,我想在redirect()助手上添加自定义方法,例如: redirect()->custom(...$params) 是否可以执行此操作?如果愿意,可以在重定向程序类上宏一个自定义方法。在服务提供商的boot方法中,您可以定义宏: use Illuminate\Routing\Redirector; public function boot() { Redirector::macro('custom', function ($your, $arguments, $here) {
redirect()->custom(...$params)
是否可以执行此操作?如果愿意,可以在
重定向程序
类上宏一个自定义方法。在服务提供商的boot
方法中,您可以定义宏:
use Illuminate\Routing\Redirector;
public function boot()
{
Redirector::macro('custom', function ($your, $arguments, $here) {
...
});
}
然后,您可以按自己喜欢的方式访问它:
redirect()->custom(...);
重定向程序
从5.5版开始就可以进行宏操作。如果愿意,可以在重定向程序
类上对自定义方法进行宏操作。在服务提供商的boot
方法中,您可以定义宏:
use Illuminate\Routing\Redirector;
public function boot()
{
Redirector::macro('custom', function ($your, $arguments, $here) {
...
});
}
然后,您可以按自己喜欢的方式访问它:
redirect()->custom(...);
重定向器
自5.5版以来一直是可宏操作的。请查看:照亮\路由\重定向器
,从重定向()返回的内容是可宏操作的itself@lagbox你能解释更多吗?看看:illighte\Routing\Redirector
,从redirect()
返回的内容,是宏观的吗itself@lagbox你能再解释一下吗?