I'm trying to save changes to a record in one database table, that has a composite key of 2 elements. When i try to use the Model::updateOrCreate or, Model::firstOrCreate methods, i get an error from the database, which tells me the id does not exists. Looks like that laravel, when creating the query, is ignoring the primery keys i've mentioned.
My model:
class CatalogueCatLanguage extends Model
{
public $incrementing = false;
protected $table = "CatalogueCatLanguages";
protected $fillable = ["cataloguecategory_id","language_id","name","description"];
protected $primaryKey = ["cataloguecategory_id","language_id"];
}
My code inside the controller method:
CatalogoCatLingua::updateOrCreate(
[
"cataloguecategory_id"=>$trad["category"],
"language_id"=>$trad["language"]
],[
"name"=>$trad["langName"],
"description"=>$trad["langDescription"]
]
);
The error i get when i have the "primaryKey" property:
Illegal offset type in isset or empty
The error i get when i have the "primaryKey" property commented:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'
I've already tried several combinations and ways of doing this, however i'm not getting what is causing this error.
Thank you, in advance.