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

AlexeiKo
AlexeiKo

Hey, I have a view which making new concert. I want to choose from user table only those users who are in producer group. Didnt find any doc for such relation/filter

Can anyone advice? I feel that ist easy, but cannot figure it out.

thanks

daftspunky
daftspunky

Take a look at the RainLab.User plugin, it has an example of filtering the users by group.

AlexeiKo
AlexeiKo

in the backend? coz i know how to do it in the front (im working with rainlab user plugin)

AlexeiKo
AlexeiKo

in field.yaml

  producer:
      label: producer
      type: recordfinder
      list: $/rainlab/user/models/user/columns.yaml
      prompt: Click the %s button to find a hall
      nameFrom: name

concert.model

public $belongsTo = [ 'producer' => [ 'RainLab\User\Models\User', 'conditions' => 'group' = 1 //not working ], ];

where do I add the condition?

can you please point me into some direction? (more specific ) ) thanks

Last updated

AlexeiKo
AlexeiKo

do you mean in config_filter.yaml

scope: filterByGroup

and

public function scopeFilterByGroup($query, $filter)
{
    return $query->whereHas('groups', function($group) use ($filter) {
        $group->whereIn('id', $filter);
    });
}

Last updated

Asinox
Asinox

AlexeiKo said:

do you mean in config_filter.yaml

scope: filterByGroup

and

public function scopeFilterByGroup($query, $filter) { return $query->whereHas('groups', function($group) use ($filter) { $group->whereIn('id', $filter); }); }

Thanks i was looking for this

1-6 of 6

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