lunar icon indicating copy to clipboard operation
lunar copied to clipboard

Model extending

Open alecritson opened this issue 1 year ago • 6 comments

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.

alecritson avatar Mar 20 '24 08:03 alecritson

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 5:12pm

vercel[bot] avatar Mar 20 '24 08:03 vercel[bot]

@alecritson I've updated the parent branch and we can now see we have some conflicts. And we know we probably need to update Brands from your other PR that was merged.

glennjacobs avatar Mar 27 '24 15:03 glennjacobs

@alecritson I've updated the parent branch and we can now see we have some conflicts. And we know we probably need to update Brands from your other PR that was merged.

The conflicts should all be sorted 🤞

alecritson avatar Mar 28 '24 09:03 alecritson

InstallLunar class should be also updated right? It currently uses 'attributable_type' => Product::class, and instead it should pick the morphed name.

AidasK avatar Apr 14 '24 09:04 AidasK

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

AidasK avatar Jun 07 '24 12:06 AidasK

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.

glennjacobs avatar Jun 07 '24 12:06 glennjacobs

Oeh we need this one

RRosalia avatar Jul 19 '24 21:07 RRosalia

@alecritson going to need to fix the conflicts before this can be merged.

glennjacobs avatar Aug 22 '24 13:08 glennjacobs