Laravel get wrong table while querying -
i try insert data new table have create laravel choose wrong reverse table. instead of job_contract contract_job.
queryexception in connection.php line 636: sqlstate[42s02]: base table or view not found: 1146 table 'job.contract_job' doesn't exist (sql: insert
contract_job
(contract_id
,job_id
) values (2, 4))
i new in laravel. know way laravel defines names of tables
a quote relation table:
the role_user table derived alphabetical order of related model names, , contains user_id , role_id columns.
in case contract_job contract_id , job_id.
and quote:
however, free override convention. may passing second argument belongstomany method:
return $this->belongstomany('app\role', 'user_roles');
so guess need pass correct table name second param belongstomany method(s) this:
//in contract model return $this->belongstomany('app\job', 'job_contract');
and
//in job model return $this->belongstomany('app\contract', 'job_contract');
quotes laravel docs
Comments
Post a Comment