예제 #1
0
 /**
  * get tag id if exists or create it if not exists
  *
  * @return array
  */
 public function getSaveValue($value)
 {
     $tags = explode(",", implode(",", $value));
     $ids = [];
     foreach ($tags as $name) {
         if (empty($name)) {
             continue;
         }
         $created = Tag::firstOrCreate(['name' => $name]);
         $ids[] = $created->id;
     }
     return $ids;
 }