拉拉维尔 5 |用以前的记录覆盖记录 |乌班图


Laravel 5 | Overwrites record with previous record | Ubuntu

在我的代码中,我尝试使用"php artisan tinker"一次添加多条记录。

我的输入:

  $tag = new App'tags
     => App'tags {#666}
  $tag->name = 'General'
     => "General"
  $tag->save()
     => true

然后我得到,

  App'tags::get()
  => Illuminate'Database'Eloquent'Collection {#696
 all: [
   App'tags {#702
     id: "7",
     name: "General",
     created_at: "2016-02-11 05:18:33",
     updated_at: "2016-02-11 05:18:33",
   },
 ],
 }

在我添加另一个之后,

$tag->name = 'Private'
=> "Private"
$tag->save()
=> true

然后我又得到了,

App'tags::get()
   => Illuminate'Database'Eloquent'Collection {#694
 all: [
   App'tags {#692
     id: "7",
     name: "Private",
     created_at: "2016-02-11 10:48:59",
     updated_at: "2016-02-11 05:18:59",
   },
 ],
}

我也尝试"::all()",我得到相同的结果。

我的代码有什么问题。

在设置$tag->name = 'Private'之前,您不会创建新标记

首先再次运行$tag = new App'tags