【发布时间】:2015-10-05 23:17:10
【问题描述】:
我有这些表
Hotels:
id = auto increment
name_hotel = text
....
Rooms:
id = auto increment
id_room = auto increment (just in same hotel)
hotel_id = integer
...
在房间表中,我有三列(id = 自动增量,id_room = 我想让此列自动增加,但仅在 1 家酒店中,每家酒店添加房间的 id_room 将为 1、2、3、4)
例子:
id id_room hotel_id
1 1 4
2 2 4
3 3 4
4 1 (start again) 5(new hotel)
5 4 4
6 2 5
可以在 laravel 模型 Eloquent 中实现
【问题讨论】:
标签: php laravel laravel-4 eloquent