I am trying to use this relationship type in my models such as:
One Job belongs to a Client
One Job has many Sessions
Session belongs to One Job
I would like to retrieve the client through the job inside the session form.
in the model Session
, I then define:
public $hasOneThrough = [
'client' => [
\Inherent\CoachCamp\Models\Client::class,
'through' => \Inherent\CoachCamp\Models\Job::class,
],
but this does not work, I have a long SQL error on the backend when trying to open up a session form detail.
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'inherent_coachcamp_jobs.session_id' in 'field list' (SQL: select `inherent_coachcamp_clients`.*, `inherent_coachcamp_jobs`.`session_id` as `laravel_through_key` from `inherent_coachcamp_clients` inner join `inherent_coachcamp_jobs` on `inherent_coachcamp_jobs`.`id` = `inherent_coachcamp_clients`.`job_id` where `inherent_coachcamp_jobs`.`session_id` = 4 and `inherent_coachcamp_clients`.`deleted_at` is null limit 1)" on line 669 of /Users/christophevidal/Sites/oc-chrisvidalcoaching/vendor/laravel/framework/src/Illuminate/Database/Connection.php
or I have this error as well in some case:
Call to undefined method October\Rain\Database\Relations\HasOneThrough::getSimpleValue()