'integer', 'user_id' => 'integer', 'status' => 'integer', 'created_at' => 'datetime' ]; /** * 获取群聊成员 */ public function members() { return $this->hasMany(UsersGroupMember::class, 'group_id', 'id'); } /** * 判断用户是否是管理员 * * @param int $user_id 用户ID * @param int $group_id 群ID * @return mixed */ public static function isManager(int $user_id, int $group_id) { return self::where('id', $group_id)->where('user_id', $user_id)->exists(); } /** * 判断用户是否是群成员 * * @param int $group_id 群ID * @param int $user_id 用户ID * @return bool */ public static function isMember(int $group_id, int $user_id) { return UsersGroupMember::where('group_id', $group_id)->where('user_id', $user_id)->where('status', 0)->exists(); } }