I am currently trying to filter through an Input string to find the single hashtags that a user wants to be displayed with his photo. However, I am currently getting inserts in
Try this:
$str = $hashtag_string;
preg_match_all('/#(\w+)/', $str, $matches);
foreach ($matches[1] as $hashtag_name) {
$hashtag = Hashtag::firstOrCreate(array('hashtag' => $hashtag_name));
}
You could then, in this foreach loop, connect those hashtags to a post (or in your case a photo) or sth.