<?php

namespace App\Models;

use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;

class MemberGroup extends Model
{
    use ModelTrait;

    protected $guarded = ['description'];

    /**
     * 当前组会员列表
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function lists()
    {
        return $this->hasMany(Member::class, 'group_id');
    }

    public function description()
    {
        $lang = config('lang') ?: config('setting.lang');

        return $this->hasOne(MemberGroupDescription::class, 'group_id')->where('lang', $lang);
    }
}
