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

Convert Eloquent models to use the new Accessor & Mutator methods #1371

Open
mikeburg opened this issue Jan 19, 2023 · 0 comments
Open

Convert Eloquent models to use the new Accessor & Mutator methods #1371

mikeburg opened this issue Jan 19, 2023 · 0 comments

Comments

@mikeburg
Copy link
Contributor

Laravel 9 introduced new attribute accessor and mutator methods . The two big advantages are the accessor values are cached, and a single method is only required to define both an accessor and/or mutator.

https://laravel.com/docs/9.x/eloquent-mutators#accessors-and-mutators

While there are no plans by the Laravel authors to deprecate the older setNameAttribute() / getNameAttribute() methods anytime soon, the older method is no longer recommended for newer code.

The work invoked is to go through all the files in app/Models folder and convert the models to use the newer methods. The major of the {get,set}NameAttribute functions are fairly simple and consist of a single line.

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