A model defined a $belongTo
relationship using
"external_platform_resource_link" => [
ExtResourceLink::class,
'scope' => 'isActiveWithoutGlobalScope',
'key' => 'external_platform_resource_link_id', // key coolumn on Course model
'otherKey' => 'resource_link_id' // otherKey column on related model
],
when I try to access the relation $this->external_platform_resource_link
, I got an exception
and when I look in DebugBar at the sql query generated it seems that it is not using the proper key
select * from `ext_resource_links` where
`ext_resource_links`.`id` = 'TPQI-VC033' and
`ext_resource_links`.`site_id` = 1 limit 1
And also, It does not use the defined scope isActiveWithoutGlobalScope
in the relation definition.
it should generate this sql as per the relation definition for the otherKey binding
select * from `ext_resource_links` where
`ext_resource_links`.`resource_link_id` = 'TPQI-VC033'
If this is a bug, it would be strange indeed, so I am guessing I am doing something wrong, but what ?