报告辅助函数的laravel附加参数

时间:2018-05-23 13:36:48

标签: laravel helper-functions

我想为laravels报告辅助函数提供一个额外的参数,所以我可以用这种方式调用它:

report($exception, 'Some additional info');

因此我更改了app / Exceptions / Handler类:

public function report(Exception $exception, string $message = null)
{
    if($message) {
        SendErrorMails::raw($message, $exception->getMessage());
    }
    parent::report($exception);
}

然而,IDE仍然抱怨它只需要1个参数。

1 个答案:

答案 0 :(得分:0)

report帮助程序异常处理程序的report方法。

你必须像这样创建自己的助手

function customReport(Exception $exception, string $message = null) {
    // Call the exception handler report method here
}

有关详细信息,请参阅report帮助程序代码here