Skip to content

Extending a model erases relations instead of merging them #314

Answered by tschallacka
tschallacka asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up writing my own little utility library, that can be used by anyone that wishes to transport relationships defined in the parents to the current instance, by adding one class to the $implement array.

https://github.com/tschallacka/storm-inherit-relations

composer require tschallacka/storm-inherit-relations ^1.0

Usage

In a model in which you wish to glean the relationships defined in
the parents add this to your $implements array:

public $implement = [\Tschallacka\StormInheritRelations\Behavior\InheritRelations];

Model example:

<?php
namespace Tschallacka\Example\Attribute;

use Winter\Storm\Database\Model;
use Tschallacka\StormInheritRelations\Behavior\InheritRelations;

class At…

Replies: 4 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@tschallacka
Comment options

Comment options

You must be logged in to vote
6 replies
@LukeTowers
Comment options

@tschallacka
Comment options

@LukeTowers
Comment options

@tschallacka
Comment options

@LukeTowers
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tschallacka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants