laravel 数据库通知存储 url 添加 \\ 到 //

laravel database notification store url added \\ to //

有谁知道为什么数据库通知 url 在 // 上添加了 \?

风景

我有一个通知 table 我想在通知 class 中存储一个 url 作为数据数组,但是添加了 url \ ,下面是我的代码,当我使用 eloquent url 时,无论我在数据库中传递什么,都没有得到 strip 意思存储。

public function toDatabase()
{
    return [
        // 'msg' => "Your Comment On ". $this->post->getAttributes()['title'] ." Was Approved Please click <a href='".route('$this->post->slug')."'>here</a> to view it",

        'msg' => "https://google.com" ,
    ];
}

当我调用通知时我的数据库中实际存储了什么 class

{"msg":"https:\/\/google.com"}

看起来他们已经添加了 mysql 预防措施,但是查询生成器是无注入的,如文档中所述,如果我错了请纠正我 谢谢

您的通知 table 中实际存储的是 json 格式,如您所见,它是 key:value 对 json

{"msg":"https:\/\/google.com"}

要获取您的通知数据,您需要 json_decode() 这样的数据

json_decode($notification->data);

你也可以,参考这个问题“why-are-forward-slashes-escaped”来了解更多关于转义正斜杠的信息

我想到的另一个转折点是对 url 进行编码,然后存储在 db