@@ -45,6 +45,11 @@ class DistAdminDistributor extends EloquentRepository
{
$id = getDistributorId();
$row = Model::find($id);
+ if ($row) {
+ foreach ($row->getAttributes() as $key => $value) {
+ $row->{$key} = $value ?? ''; // 如果值为 null,替换为空字符串
+ }
return $row;
}
@@ -11,11 +11,7 @@ class DistAdminDistributor extends Model
use HasDateTimeFormatter;
protected $table = 'dist_admin_distributor';
- //把null转为''
- public function setNameAttribute($value)
- {
- $this->attributes['name'] = $value ?? '';
- }
+
/*
* 用户一对多关联