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

Casting attributes in the model #58

Open
PlayeRom opened this issue Feb 26, 2024 · 0 comments
Open

Casting attributes in the model #58

PlayeRom opened this issue Feb 26, 2024 · 0 comments

Comments

@PlayeRom
Copy link

When I use attribute casting in the model, such as dates, or enum type, then this library does not deal with it, such as:

protected $casts = [
    'status' => Status::class,
    'start_date' => 'date:Y-m-d',

For dates it displays the full date format, instead of the one I defined (Y-m-d). With enums there is a crash because it needs a string type and gets an enum.

From what I checked, it would be enough to use $model->toArray() in the addCsvRows function. Serializing to a table will take into account the cast and will convert all attributes to valid string values.

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