public static function firstByTitleOrCreate($title, $locale = null)
    {
        $tag = Tag::whereTranslation('title', $title, $locale)->first();

        if (is_null($tag))
        {
            $attributes = compact('title');

            if ($locale)
            {
                $attributes = [$locale => $attributes];
            }

            $tag = Tag::create($attributes);
        }

        return $tag;
    }
public static function firstByTitleOrCreate($title, $locale = null)
    {
        $tag = Tag::whereTranslation('title', $title, $locale)->first();

        if (is_null($tag))
        {
            $attributes = compact('title');

            if ($locale)
            {
                $attributes = [$locale => $attributes];
            }

            $tag = Tag::create($attributes);
        }

        return $tag;
    }
public static function firstByTitleOrCreate ( $ title , $ locale = null ) { $ tag = Tag :: whereTranslation ( 'title' , $ title , $ locale ) -> first ( ) ; if ( is_null ( $ tag ) ) { $ attributes = compact ( 'title' ) ; if ( $ locale ) { $ attributes = [ $ locale => $ attributes ] ; } $ tag = Tag :: create ( $ attributes ) ; } return $ tag ; }
Finds a tag by title or creates it

@param string $title
@param string $locale
@return Tag
Finds a tag by title or creates it