[英]laravel database notification store url added \\ to //
有谁知道为什么数据库通知 url 在 // 上添加了 \?
I have a notification table I want to store a url as data array inside notification class, but the url get added \, below is my code, when I using the eloquent url is not getting strip meaning store whatever I pass in database.
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 预防措施,但是查询生成器是无注入的,如文档中所述,如果我错了,请纠正我谢谢
实际存储在通知表中的是 json 格式,如您所见,它是key:value
对 json
{"msg":"https:\/\/google.com"}
要获取通知的数据,您需要像这样json_decode()
数据
json_decode($notification->data);
您也可以参考这个问题“ why-are-forward-slashes-escaped ”以了解有关 escaping 正斜杠的更多信息
我想的另一个转身是编码 url 然后存储在数据库中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.