I have two models: User
& Tag
. They have a many-to-many relation.
Table users : id, email, password...
Table tags : id, name...
table tag_user: id, tag_id, user_id
If can use this code to get an array with all Tag
s a User
has:
$tagArray = User::find($user_id)->tags;
However, I can't find a quicker way to get a simple array with all the tags ids. Something like this:
$tagIdArray = array(1, 2, 3);