thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Undefined model relationships:morphMany ... #3024

Open scbing opened 6 years ago

scbing commented 6 years ago

Model relation

hasManyThrough
morphTo
morphMany
morphToMany
morphedByMany

Each project will basically use the model relationship here.

Is there a support for the plan?

marktopper commented 6 years ago

We are open to pull requests

emptynick commented 6 years ago

Morphing is a really difficult topic, as the possible Models are unpredictable. But maybe someone finds a way.

karneaud commented 4 years ago

I was able to modify the blade templates to accommodate the relationships in relationship-partial.blade.php/ relationship-new-modal.blade.php.

  <option value="morphTo" @if(isset($relationshipDetails->type) && $relationshipDetails->type == 'morphTo'){{ 'selected="selected"' }}@endif>Morph To</option>
                <option value="morphToMany" @if(isset($relationshipDetails->type) && $relationshipDetails->type == 'morphToMany'){{ 'selected="selected"' }}@endif>Morph To Many</option>

and the javascript to allow input of the pivot table and adding some additional input to accept a "morph_column" which would be used to morphToMany(\Model:class, *morph_column*)

<p class="morph_column"><strong>Morph Column <span class="label_table_name"></span>: </strong>
                                        <span><input type="text" class="form-control" name="morph_column" placeholder="Morph Column" value="{{ $relationshipDetails->morph_column ?? ''}}"></span>
                                                        </p>

the problem I am having is that it does not seem to "save" the morph_column in the JSON details

depak379mandal commented 3 years ago
* Laravel Version: 5.6.17

* Voyager Version: 1.0.*

* PHP Version:

* Database Driver & Version:

Model relation

hasManyThrough
morphTo
morphMany
morphToMany
morphedByMany

Each project will basically use the model relationship here.

Is there a support for the plan?

Me Too waiting for morph relationships in voyager.