Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Update ShopModel trait boot method #517

Merged
merged 3 commits into from
Jul 7, 2020
Merged

Update ShopModel trait boot method #517

merged 3 commits into from
Jul 7, 2020

Conversation

bilfeldt
Copy link
Contributor

@bilfeldt bilfeldt commented Jul 4, 2020

This PR simply renames the boot method of the trait ShopModel so that this method is not accidentally overriden by a boot method set on the User model. This is done by use of Eloquents automatic boot naming conventions for traits - please see this guide by Tighten Co for more information.

Without PR:

A User model using the ShopModel trait might also implement its own protected static function boot() which causes the same method on the ShopModel trait to be overriden, causing the global scope to not be registred.

With this PR:

A User model using the ShopModel trait might also implement its own protected static function boot() which does not conflict with the ShopModel trait since Eloquent will automatically call the method bootShopModel() hence causing the global scope to be registred when booting the User model.

bilfeldt added 3 commits July 5, 2020 00:15
Renames the boot method of the trait so that is cannot be overriden by the model implementing the trait while it will automatically be booted by eloquent.
End DocBlock with a dot (.)
@bilfeldt
Copy link
Contributor Author

bilfeldt commented Jul 6, 2020

@osiset tests fixed, let me know if anything is unclear 👍

@gnikyt
Copy link
Owner

gnikyt commented Jul 7, 2020

@bilfeldt Sorry been busy. Looks great and a very well idea, never thought about this use case. Accepted.

@gnikyt gnikyt merged commit b8f1fe4 into gnikyt:master Jul 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants