【发布时间】:2017-09-20 09:35:06
【问题描述】:
我有两个表,一个是用户,它是父表,另一个是帖子(子)表,它的列是
公共函数向上(){ Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->string('title'); $table->string('body'); $table->timestamps(); } }我已经指定了
$this->hasOne('Post');
与用户模型的关系。现在我想将数据插入到帖子表中,在表格中我可以将数据保存到标题和正文列到相应的 ID 中。
【问题讨论】: