slavkovrn / yii2-chat
The Yii2 extension module to chat registered users.
Installs: 511
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 2
Open Issues: 1
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0
This package is auto-updated.
Last update: 2024-11-12 04:32:07 UTC
README
The Yii2 extension module to chat for registered users using User model of advanced template.
Installation
The preferred way to install this extension is through composer.
Either run:
composer require slavkovrn/yii2-chat
or add
"slavkovrn/yii2-chat": "*"
to the require section of your composer.json
file.
Usage
1.add link to ChatModule in your config
return [ 'modules' => [ 'chat' => [ 'class' => 'slavkovrn\chat\ChatModule', 'numberLastMessages' => 30, ], ], ];
- in your User model you should define two getters for name and link to icon of registered User
in my case that's
namespace app\models; ... use app\models\Profile; class User extends ActiveRecord implements IdentityInterface { public function getChatname() { return Profile::find()->where(['id' => Yii::$app->user->id])->one()['name']; } public function getChaticon() { return Profile::find()->where(['id' => Yii::$app->user->id])->one()['photo']; } ...
and now you can chat with registered users via http://yoursite.com/chat url