如何在Laravel 5中的模型中放置组合键? [英] How I can put composite keys in models in Laravel 5?

查看:69
本文介绍了如何在Laravel 5中的模型中放置组合键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个带有两个主键(id和language_id)的表,需要将其放入模型中.模型中的默认primaryKey(Laravel 5中的Model.php)是id,我希望primaryKeys将是id和id_language.我试着用数组或带','的字符串来放置它,但是它不起作用.它说我无法在String中转换数组.

I have in my DataBase a table with two primary keys (id and language_id) and I need put it in my models. The default primaryKey in Models (Model.php in Laravel 5) is id, and I want that the primaryKeys will be id and id_language. I tried put it with arrays or a String with ',' but it doesn't work. It says me that the array could not be converted in String.

请帮助.

谢谢!

推荐答案

您不能.口才不支持复合主键.

You can't. Eloquent doesn't support composite primary keys.

这是与此相关的Github问题.

这篇关于如何在Laravel 5中的模型中放置组合键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆