我在Laravel 10上安装了望远镜。TelescopeServiceProvider.php
中的register()
方法目前包含:
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->environment('local')) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag() ||
$entry->isSlowQuery() ||
$entry->isClientRequest() ||
($entry->type === EntryType::REQUEST && in_array('slow', $entry->tags)) ||
($entry->type === EntryType::GATE && $entry->content['result'] !== 'allowed') ||
$entry->type === EntryType::LOG ||
$entry->type === EntryType::JOB ||
$entry->type === EntryType::EVENT ||
$entry->type === EntryType::COMMAND ||
($entry->type === EntryType::MAIL && $entry->content['mailable'] !== 'App\Mail\Communication\CommunicationMailable');
});
字符串
正如你从最后几行看到的,我试图记录每个Mailable**,除了**CommunicationMailable
类。我目前正在使用Telescope设置的mailable
属性进行字符串比较,但我真的不喜欢它,因为如果我改变了mailable类的路径,我必须记住每次都手动更改字符串。有没有更好的方法?
1条答案
按热度按时间0pizxfdo1#
Telescope设置的
mailable
属性对应于完全限定的类名,因此您可以使用::class
常量以编程方式获取它(PHP docs)。在我的例子中:1.在
TelescopeServiceProvider.php
中导入CommunicationMailable
类:use App\Mail\Communication\CommunicationMailable;
个1.使用
::class
常量而不是手动编写的字符串(来自问题中的代码):字符串