Skip model accessor

后端 未结 4 844
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 13:56

I got a model called Run which contains this method:

public function getNameAttribute($name){
    if($name == \'Eendaags\')
        return $this->race_edition         


        
4条回答
  •  盖世英雄少女心
    2021-01-31 14:41

    since Laravel 7.x there is a new approach to access intact attribute:

    // that skips mutators
    $model->getRawOriginal('name');
    

    https://laracasts.com/discuss/channels/testing/how-to-disable-casting-during-testing

提交回复
热议问题