【发布时间】:2017-05-15 16:46:25
【问题描述】:
这是我的结构,我想在laravel中连接这两个表,怎么做?
发布表:
public function up()
{
Schema::create('post', function (Blueprint $table) {
$table->increments('post_id');
$table->string('post');
$table->integer('time');
$table->string('host');
$table->integer('vote_up');
$table->integer('vote_down');
$table->foreign('id_fk')->references('id')->on('users');
$table->timestamps();
});
}
用户表:
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->date('dob');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
【问题讨论】:
-
“连接这两个表”是什么意思?您只想在模型之间创建关系吗?
标签: database laravel database-connection laravel-facade