Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about attribute casting #114

Open
blorange2 opened this issue Jul 12, 2024 · 0 comments
Open

Question about attribute casting #114

blorange2 opened this issue Jul 12, 2024 · 0 comments

Comments

@blorange2
Copy link

In my code I have been doing the following to explicitly set boolean values, the null part is redundant but anyway.

/**
 * Set the attribute or explicity return null.
 *
 * @param [type] $value
 */
public function setSubsidaryRuleCAttribute($value)
{
    $this->attributes['Subsidary_Rule__c'] = boolval($value ?? null);
}

Recently I wondered whether or not because the Lester\EloquentSalesForce\Model extends an abstract model class that itself extends a vanilla Eloquent model, whether you could use the $casts property?

So I tried it:

protected $casts = [
    'Subsidary_Rule__c' => 'boolean',
];

However, when testing I get the following:

Cannot deserialize instance of boolean from VALUE_STRING value 1 or request may be missing a required field at [line:1, column:2]

I'm wondering whether I don't understand $casts or whether this is a bug?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant