多对多

作者: 搁浅_6a34 | 来源:发表于2017-11-18 20:50 被阅读0次

    可用方法

    $user ->roles ()->save ()

    $user ->roles ()->savemany  ()

    save 和savemany 接收模型实例

    $user ->roles ()->create()

    $user ->roles ()->createmany()

    接收数组,分别一维数组和二维数组

    attach ()接收id 或者数组

    detach ()接收id 或者数组

    sync ()接收数组

    toggle ()接收数组

    更新belongto 关联

    ->associate($account)更新外键

    取消dissociate($account)


    更新父级时间戳

      protected $touches = ['post'];

    相关文章

      网友评论

          本文标题:多对多

          本文链接:https://www.haomeiwen.com/subject/bojyvxtx.html