You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 'column' filed type can be used with HasMany fields to set the foreign key according to the readme. But if I get it right this isn't the case, as it uses 'model_id' as foreign key even when this value is set.
It seems this line is where a possible fix can be applied (I solved it by a simple if statement checking if the 'column' value is available and using it instead of $this->fk() if so):
Foreign key handling is generally not written to support non-standard foreign keys in Sprig. For example the assumtion (by each model having one fk() method) that the foreign key for a given model is the same in all other relationships is a bad one - you can't have a model that relates to two users, one as an author and one as an editor for example.
The 'column' filed type can be used with HasMany fields to set the foreign key according to the readme. But if I get it right this isn't the case, as it uses 'model_id' as foreign key even when this value is set.
It seems this line is where a possible fix can be applied (I solved it by a simple if statement checking if the 'column' value is available and using it instead of $this->fk() if so):
http://github.com/shadowhand/sprig/blob/master/classes/sprig.php#L355
The text was updated successfully, but these errors were encountered: