laravel-livewire-tables icon indicating copy to clipboard operation
laravel-livewire-tables copied to clipboard

Add support for MorphOne relationships

Open DanielGSoftware opened this issue 1 year ago • 0 comments

Take the following relationship Model Address, which has a morphTo() method and has addressable_id and addressable_type columns. Model User , which has MorphOne() that points to the address model.

If I have a user table, and I want to display the street of the address, I would do Column::make('street', 'address.street').

This will give the following exception: Rappasoft\LaravelLivewireTables\Views\Column::setTable(): Argument #1 ($table) must be of type string, null given, called in /Users/danielgebben/Documents/LenderSpender/platform/vendor/rappasoft/laravel-livewire-tables/src/Traits/Helpers/ColumnHelpers.php on line 24.

This is because MorphOne is not supported when making the columns.

All Submissions:

  • [X] Have you followed the guidelines in our Contributing document?
  • [X] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. [X] Does your submission pass tests and did you add any new tests needed for your feature?
  2. [x] Did you update all templates (if applicable)?
  3. [x] Did you add the relevant documentation (if applicable)?
  4. Did you test locally to make sure your feature works as intended? Yes

Changes to Core Features:

  • [X] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [x] Have you written new tests for your core changes, as applicable? Not yet, I'd first like this to pass and then I'll add tests
  • [X] Have you successfully ran tests with your changes locally?

DanielGSoftware avatar Jul 14 '22 15:07 DanielGSoftware