Open bmcn99 opened 2 years ago
https://github.com/topclaudy/compoships/pull/122
Hi, 2.1.3 feature works for hasOne
, hasMany
, fell free to make a PR for belongsTo
Also give the file and the line of the exception,
Did you try the inverse?
return $this->belongsTo('App\Models\PizzaPrice', ['pizza_id', 'size_id'], ['pizza_id', DB::raw('table_name.size_id')]);
Also try this https://github.com/erikn69/compoships/commit/005a39cdaf8de9a4d198ed56b4ef427ad8f0a116
My current relationship using compoships works well:
return $this->belongsTo('App\Models\PizzaPrice', ['pizza_id', 'size_id'], ['pizza_id', 'size_id']);
but after updating to 2.1.3 and altering it to use:
return $this->belongsTo('App\Models\PizzaPrice', ['pizza_id', DB::raw('size_id')], ['pizza_id', 'size_id']);
orreturn $this->belongsTo('App\Models\PizzaPrice', ['pizza_id', DB::raw('table_name.size_id')], ['pizza_id', 'size_id']);
in order to test the new functionality it produces the following error:
array_key_exists(): The first argument should be either a string or an integer
Am I not using this correctly? My end goal would be a relationship that is a few degrees removed and look something like this:
But that will not work since it dies when trying to use DB::raw('F.foreignKey2'). Please let me know if I can provide any further information and thank you.