Answer the question
In order to leave comments, you need to log in
How to make a mutator so that if there is a link in the text, the model will give it as an html link?
The idea is this. There is a text field in the table, and if there is a link among the text, it should display this link as in the html link tags. For example, if this field contains
Some text bla bla http://mysite/bla/bla дальше рыба текст
so that the model gives it asSome text bla bla <a href="http://mysite/bla/bla">http://mysite/bla/bla</a>дальше рыба текст
. How to do it in a mutator? Or not in the mutator.
Answer the question
In order to leave comments, you need to log in
public function getTextFormattedAttribute()
{
$text = $this->attributes['text'];
// Тут делаете что хотите с вашим тестом. Находите ссылки и т.д., удаляете или подсвечиваете их
return $text;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question