$weid, 'crowd' => $crowd])->find(); if (!empty($chat)) { return $chat->id; } $chat = self::where(['weid' => $weid, 'crowd' => $crowdor])->find(); if (!empty($chat)) { return $chat->id; } $chat = self::create(['weid' => $weid, 'crowd' => $crowd, 'time' => time()]); return $chat->id; } public static function getcrowd($id) { $chat = self::where(['id' => $id])->find(); return $chat->crowd; } }