Imagine you have a multi-language application. The admin section has English set as the app's locale, but you want tags to be input by your admins in another language by default, for instance Dutch.
In this case, you can set the default language for tags to Dutch.
First create, your own Tag
model and override the function getLocale()
.
namespace App\Models;
use Spatie\Tags\Tag as SpatieTag;
class YourTag extends SpatieTag
{
public static function getLocale(): string
{
return 'nl';
}
}
Next, change the default Tag
class in tags config (config/tags.php
):
return [
'slugger' => null,
'tag_model' => App\Models\YourTag::class,
];