Created
March 14, 2016 09:37
-
-
Save permatis/66e50e8da23139d45313 to your computer and use it in GitHub Desktop.
Filtering tags if exists in database records.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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