Laravel 8 标签
Telescope 允许你通过 tag 搜索条目。 通常,标签是 Eloquent 模型的类名或经过身份验证的用户 ID, 这些标签会自动添加到条目中。有时,您可能希望将自己的自定义标签附加到条目中。 你可以使用 Telescope::tag 方法。 tag 方法接受一个回调,该回调应返回一个标签数组。回调返回的标签将与 telescope 自动附加到条目的任何标签合并。您应该在 TelescopeServiceProvider 中调用 tag 方法:
use Laravel\Telescope\Telescope;
/**
* 注册应用服务
*
* @return void
*/
public function register()
{
$this->hideSensitiveRequestDetails();
Telescope::tag(function (IncomingEntry $entry) {
if ($entry->type === 'request') {
return ['status:'.$entry->content['response_status']];
}
return [];
});
}