I am trying to save hashtags to a database. At the moment they are saved in a single row with the image_id and the following format:
Hashtags: #test bla #test #test
DB: test,test,test
What do I have to do to save every single hashtag in a single database row maintaining the correstpondig photo_id?
Here is how I save the hashtags:
$hashtag = new Hashtag;
$hashtag->photo_id = $photo->id;
$hashtag_string = Input::get('hashtags');
$str = $hashtag_string;
preg_match_all('/#([^\s]+)/', $str, $matches);
$hashtags_final = implode(',', $matches[1]);
$hashtag->hashtag = $hashtags_final;
$hashtag->save();