Skip to content

Eloquent Model: Implement ArrayAccess interface#38

Closed
franzliedke wants to merge 2 commits intoilluminate:masterfrom
franzliedke:patch-1
Closed

Eloquent Model: Implement ArrayAccess interface#38
franzliedke wants to merge 2 commits intoilluminate:masterfrom
franzliedke:patch-1

Conversation

@franzliedke
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants