This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jlongo
jlongo

Hi all In first place i hope everybody has a great Christmas period, and also desire a great New Year too!

I have a problem i can't face how to get the group name (or groups) associated with a user on a list of users on frontend.

I have at code section:

<?php 
    use October\Rain\Auth\Models\User;
    public function onStart() {
    $this['utilizadores'] = User::orderBy('last_seen', 'desc')->paginate(25);
}
?>

and in html something like:

{% for utilizador in utilizadores %} 
<tr> 
<td>{{ utilizador.name }}</td> 
<td>{{ utilizador.email }}</td> 
<td>{{ utilizador.created_at }}</td> 
<td>{{ utilizador.last_seen }}</td>
<td>{{ utilizador.userGroup.group.name }}</td> 
</tr>
{% endfor %}

I have played with the last value without any luck... Some ideia out there ???

TIA

JL

kasperbb9853952
kasperbb9853952

In case anyone stumbles upon this, here is the solution:

{% for user in users %}
    {% for group in user.groups %}
        {{ group.name }}
    {% endfor %}
{% endfor %}

A tip for figuring out how to do this kind of thing: look up the tables in the database.

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.