Closed vaawebdev closed 4 years ago
This is a Laravel issue, please see https://github.com/laravel/framework/issues/32546.
@staudenmeir could you integrate the query to select main relation model without prefix?
That would be a breaking change.
Thanks @taylorotwell.
@vaawebdev The commit also fixes this issue and will be available in the next Laravel release.
@taylorotwell @staudenmeir thanks a lot for the update, appreciated!
I use Laravel 7 Route implicit bindings (https://laravel.com/docs/7.x/routing#implicit-binding) with custom keys for my
hasManyDeep
relation. Model relation method codepublic function forms() { return $this->hasManyDeep( Form::class, [ CheckupService::class, Service::class, FormService::class, ] ); }
Route code
Route::name('store') ->post('{checkup:id}/{form:code}', 'UserCheckupReportController@store') ->where(['form' => '[A-Z]+']);
This way Laravel guesses that the Checkup has relation forms and searches form with the "code" column.
As soon as the query for the hasManyDeep has the "code" column with forms prefix like this: "forms.code" I get the error
SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference \"code\" is ambiguous
I user laravel v7.6.2 and postgres alpine