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

Model extending #1661

Open
wants to merge 116 commits into
base: 1.x
Choose a base branch
from
Open

Model extending #1661

wants to merge 116 commits into from

Conversation

alecritson
Copy link
Collaborator

This PR looks to build on the current work done for model extending and includes but not limited to the following changes:

  • Filament resources use the model contract for DI
  • Change to use Laravel's morphMap instead of having concrete classes in the database for polymorphic relationships
  • There was an issue with custom models when they extended Lunar ones, the newFactory method didn't like having the return type.
  • Added a addDir
  • Tweaked guessContractClass to take namespace into account as not all Lunar models (from addons) will have the same namespace
  • Added addDirectory method to prevent excessive calls to replace or add methods.
  • Updated relationships to use modelClass()
  • Static functions should forward to the custom class when called.
  • If a custom class name is different to the one it extends i.e. App\Models\MyProduct instead of App\Models\Product it will still use the correct table name.
  • Tweaked observe method on models that use HasModelExtending to forward to the custom class even if observe is called on the Lunar model.
  • Removed redundant tests and updated docs.

Set as draft for the moment as there is a fair amount of changes so just want to double check before hitting the button.

glennjacobs and others added 30 commits December 21, 2023 14:39
Co-authored-by: wychoong <67364036+wychoong@users.noreply.github.com>
# Conflicts:
#	packages/core/src/Models/Currency.php
@alecritson alecritson changed the base branch from feature/model-extending to 1.x April 17, 2024 14:33
@glennjacobs glennjacobs changed the title Feat - Expand on model extending Model extending Apr 19, 2024
packages/core/src/LunarServiceProvider.php Outdated Show resolved Hide resolved
packages/core/src/Models/Address.php Outdated Show resolved Hide resolved
docs/core/extending/models.md Outdated Show resolved Hide resolved
docs/core/extending/models.md Outdated Show resolved Hide resolved
docs/core/extending/models.md Show resolved Hide resolved
@AidasK
Copy link

AidasK commented Jun 7, 2024

Kudos for all the work <3. But eta for this? Looks like the most needed and essential feature of v1

@glennjacobs
Copy link
Contributor

Kudos for all the work <3. But eta for this? Looks like the most needed and essential feature of v1

It'd essentially ready and on a PR. We are just trying to get some more PRs merged before that one goes in.

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.

None yet

5 participants