You are here
多对多保存关联
星期二, 2016-04-26 16:32 — shiping1
- D:\wamp\www\laravel5>php artisan tinker
- Psy Shell v0.4.1 (PHP 5.5.12 ΓÇö cli) by Justin Hileman
- >>> $article = App\Article::first();
- => <App\Article #000000000fac5aa70000000016f5b020> {
- id: 1,
- user_id: 1,
- title: "This is the first article",
- body: "This is the first article content.",
- created_at: "2015-07-25 21:18:08",
- updated_at: "2015-07-25 21:18:08",
- published_at: "2015-07-25 00:00:00",
- excerpt: null
- }
- >>> $article->tags()->attach(1);//attach 这个方法 就保存了 返回null
- => null
- 关联保存后 返回值为 null