【发布时间】:2019-04-25 16:10:17
【问题描述】:
我想知道是否可以使用查询生成器而不是使用 Eloquent 关系来引用表的外键。
我正在查看Laravel Documentation,我们可以在其中创建外键
Schema::table('posts', function (Blueprint $table) {
$table->unsignedInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
但我在查询生成器中看不到是否可以只使用外键或引用来获取用户的所有帖子
我必须使用 Eloquent 关系吗?
提前感谢您的帮助。
【问题讨论】: