framework icon indicating copy to clipboard operation
framework copied to clipboard

模型使用findOrEmpty()查询时append的疑惑

Open poetryiii opened this issue 3 years ago • 1 comments

例如: 模型内定义

protected $append = ['status_text'];

public function getStatusTextAttr(){
    return '正常';
}
---------------------------------------
User::where('id',100)->findOrEmpty();

结果不存在的话依然会调用getStatusAttr()获取器 这样是否合理 个人感觉结果不存在应该返回空模型

poetryiii avatar Jun 02 '22 08:06 poetryiii

的确是个很大问题

ooing avatar Jul 18 '22 09:07 ooing