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

Eloquent Model: Implement ArrayAccess interface #38

Closed
wants to merge 2 commits into from
Closed

Eloquent Model: Implement ArrayAccess interface #38

wants to merge 2 commits into from

Conversation

franzliedke
Copy link
Contributor

First of all, it's a convenience feature for accessing model attributes in array notation.

Secondly, it allows me to do things like url('route_name', $model_object) in my custom router and, when generating the URL, have access to all the attributes of the model. Saves me some array typing and is very flexible if you want to swap out URL schemes.

I'm currently digging into the Symfony Routing component to check whether that works there, too. If I manage to find that, this becomes much more useful.

@taylorotwell
Copy link
Member

Your isset and unset might be a little off when your model has relations since it is only checking the attributes array.

@franzliedke
Copy link
Contributor Author

Sorry, was I too slow?

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