laravel Tinker报错 BadMethodCallException with message 'Call to undefined method Illuminate\Database\Q

进行模型关联操做,php

php artisan tinker

  执行google

$user = App\Models\User::find(1)
$user->followings()->attach([2, 3])

  报错,模型关联定义都是OK的,google了一番,才发现原来是tinker的bug。直接在控制器中调用就没有报这个错误。若是你用tinker也报这个错了,试一下直接在控制器中操做。by the way,我用的是5.1版本blog

相关文章
相关标签/搜索