We have a user who is using Eloquent users for auth, and has an extra blueprint field for balance in order to show read-only data using an accessor on his model...
protected$appends = [
'balance',
];
publicfunctiongetBalanceAttribute()
{
return (int) BalanceService::getBalanceForUser($this);
}However, saving the user causes SQL error...
Column not found: 1054 Unknown column 'balance'in'field list' (SQL: update`users`set`balance`=0, `users`.`updated_at`=2022-05-0207:49:24where`id`=12)
And when trying to do this on Eloquent entries using the eloquent driver addon, this field data ends up getting saved to the data JSON column, which is also undesirable for read-only data that you might want to show in the CP.
What if we add virtual: true config option to fieldtypes to ensure these virtual fields never get saved in the first place?
We have a user who is using Eloquent users for auth, and has an extra blueprint field for
balancein order to show read-only data using an accessor on his model...However, saving the user causes SQL error...
And when trying to do this on Eloquent entries using the eloquent driver addon, this field data ends up getting saved to the
dataJSON column, which is also undesirable for read-only data that you might want to show in the CP.What if we add
virtual: trueconfig option to fieldtypes to ensure these virtual fields never get saved in the first place?