我有一个模式叫润包含此方法:跳过模式访问
public function getNameAttribute($name){
if($name == 'Eendaags')
return $this->race_edition->race->name;
return $this->race_edition->race->name.' '.$name;
}
我需要这个设置为laravel管理员,因为运行的很多都会有相同的名称和唯一的区别就是比赛的名称。但在网站上的1个地方,我只需要获取名称,而不会发生变化。这是可能的吗?
您可以切换到使用'getNameRaceAttribute'函数,该函数仅供管理员使用,并且设置管理员使用' - > name_race'字段,然后 - >名称将像通常一样。雄辩中没有“获取原始属性”功能。相关的代码:https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Eloquent/Model.php#L1839 –
试过这个,但它会带来其他问题。我想我需要在管理员中破解它。 – LHolleman