Laravel 5 |用以前的记录覆盖记录 | Ubuntu

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先再说一遍