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

Add support for model keys cast to backed enums in FormatModel #1287

Closed
saadsidqui opened this issue Dec 27, 2022 · 2 comments
Closed

Add support for model keys cast to backed enums in FormatModel #1287

saadsidqui opened this issue Dec 27, 2022 · 2 comments

Comments

@saadsidqui
Copy link
Contributor

saadsidqui commented Dec 27, 2022

  • Telescope Version: 4.10.2
  • Laravel Version: 9.x.x
  • PHP Version: 8.1.13
  • Database Driver & Version:

Description:

In Laravel\Telescope\FormatModel.php, an Eloquent model key can be cast to a backed enum, which would not be able to be cast to a string.

Steps To Reproduce:

  1. Create a model with a non-autoincrement id.
  2. Add a cast for id to a backed enum in the $casts member variable in said model
  3. Try inserting a new row of said model into the database using create or updateOrCreate etc ...

I have submitted a rough fix in a PR#1286, but I'm not too sure that will help as I don't have the full picture.

@driesvints
Copy link
Member

Thanks. Seems like you already sent in a PR so let's see how it goes. This also seems like a feature request, not a bug.

@saadsidqui
Copy link
Contributor Author

saadsidqui commented Dec 27, 2022

Thank you. It is indeed a bug and not a feature request. Laravel added support for casting model fields to backed enums, and that breaks Telescope. This in my case broke my seeders and halted development (for a while before I dug into the code and patched it locally).

The PR submitted is just a quick fix I'm using locally.

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

2 participants