"Eloquent 다대다 관계"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
3번째 줄: 3번째 줄:
;엘로퀀트 many-to-many
;엘로퀀트 many-to-many


<source lang='php'>
<syntaxhighlight lang='php'>
class User extends Model
class User extends Model
{
{
11번째 줄: 11번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
class Role extends Model
class Role extends Model
{
{
20번째 줄: 20번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:58 기준 최신판

1 개요[ | ]

Eloquent 다대다
엘로퀀트 many-to-many
class User extends Model
{
    public function roles()
    {
        return $this->belongsToMany('App\Role');
    }
}
class Role extends Model
{
    public function users()
    {
        return $this->belongsToMany('App\User');
    }
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}