Skip to content

Default properties are never overwritten by retrieval #10

@erikgaal

Description

@erikgaal

Hi there. First of all, thank you for your work on this package, I loved using it so far.

Unfortunately, I'm running into an issue when using default attributes.

class User
{
    use Fluent;

    public int $amount = 20;
}

Or as documented in the Laravel Docs.

class User
{
    use Fluent;

    public int $amount;

    public $attributes = [
        'amount' => 20,
    ];
}

Using either of these snippets, whenever retrieving a User from the database the amount property will always have the default value. Even when the amount column is set to anything else than the default value.

$user = User::first();
echo $user->amount;
// 20

I haven't been able to find why this is happening exactly, but I still wanted to report this issue. Maybe we can find a fix, or we should add this to the documentation as an incompatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions