在 rtconner/laravel-tagging 配置文件中更改显示选项

Change displayer option in rtconner/laravel-tagging config file

我对 https://github.com/rtconner/laravel-tagging 有疑问,需要一些帮助。

问题是我的标签名称在保存到数据库之前被更改了。

Tag.php 模型有突变器(不想更改,因为它在供应商目录中)

public function setNameAttribute($value)
{
    $displayer = config('tagging.displayer');
    $displayer = empty($displayer) ? '\Illuminate\Support\Str::title' : $displayer;

    $this->attributes['name'] = call_user_func($displayer, $value);
}

config/tagging.php 有

'displayer' => '\Illuminate\Support\Str::title',

我不想 'displayer' 使用“\Illuminate\Support\Str::title”,因为它会使我的标签名称首字母大写 ("echo" => "Echo" ) 并删除其他大写字母 ("HeY" => "Hey").

我应该为 'displayer' 值输入什么?

感谢您的帮助

由于配置值接受一个函数名称,您所要做的就是将其替换为一个可以按照您希望的方式转换字符串的名称。

如果您想什么都不做,可以使用一个函数:

'displayer' => 'value'

The value function returns the value it is given. (...)

https://laravel.com/docs/5.7/helpers#method-value