samedi 17 novembre 2018

LARAVEL hasManyThrough still using the ID as foreign key

Hi trying to get the rest day of a country. But I am getting error.

Basically here is the structure

Employee has SITE, Site has REGION, Region has REST DAY

I have declared this on my Employee Model

public function restdays(){ return $this->hasManyThrough('App\ref_restdays', 'App\ref_gacomsit', 'region', 'region'); }

But I get this error

[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'RUAE' to data type int. (SQL: select [ref_restdays].*, [ref_gacomsit].[region] from [ref_restdays] inner join [ref_gacomsit] on [ref_gacomsit].[id] = [ref_restdays].[region] where [ref_gacomsit].[region] in (855))

Apparently it using still the ID of my site masterfile where as I have declared to use the REGION foreign key.

Can anyone explain where is my mistake is? Appreciate for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire