【发布时间】:2015-03-02 20:07:28
【问题描述】:
我在 Laravel 4.2 上使用 Eloquent ORM 有一个主题和链接表。他们有这样的关系;
主题模型:
class Topic extends \Eloquent {
public function links()
{
return $this->belongsToMany('Link');
}
}
链接模型:
class Link extends \Eloquent {
public function topics()
{
return $this->belongsToMany('Topic');
}
}
我想像这样对链接进行分组;
05.02.2015
第一个主题
- 示例链接
- 示例链接
第二个话题
- 示例链接
- 示例链接
04.02.2015
第一个主题
- 示例链接
- 示例链接
第二个话题
- 示例链接
- 示例链接
数据库方案
主题
- 身份证
- 姓名
- created_at
- updated_at
链接
- 身份证
- 标题
- created_at
- updated_at
链接主题
- 身份证
- link_id
- topic_id
我该怎么做?我没有解决这个问题。
谢谢。
【问题讨论】:
-
您的数据库表中有哪些字段?你能给我们一些示例行吗?
-
添加了数据库方案。
标签: php mysql laravel laravel-4 eloquent