Skip to content

Instantly share code, notes, and snippets.

@permatis
Created March 14, 2016 09:37
Show Gist options
  • Save permatis/66e50e8da23139d45313 to your computer and use it in GitHub Desktop.
Save permatis/66e50e8da23139d45313 to your computer and use it in GitHub Desktop.
Filtering tags if exists in database records.
<?php
/**
* Filter tag if exists
* @param string $input Get value from input name
* @return array All tags is don't exists
*/
private function tagged($input)
{
$newTags = [];
$tags = explode(',', $input);
$getTags = $this->tag->all(['name'])->toArray();
foreach ($tags as $tag) {
if(in_array($tag, array_flatten($getTags))) continue;
$newTags[] = $tag;
}
return $newTags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment