1. Go to this page and download the library: Download bubasuma/yii2-simplechat library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace common\models;
use common\models\User;
//...
class Conversation extends \bubasuma\simplechat\db\Conversation
{
public function getContact()
{
return $this->hasOne(User::className(), ['id' => 'contact_id']);
}
/**
* @inheritDoc
*/
protected static function baseQuery($userId)
{
return parent::baseQuery($userId) ->with(['contact.profile']);
}
/**
* @inheritDoc
*/
public function fields()
{
return [
//...
'contact' => function ($model) {
return $model['contact'];
},
'deleteUrl',
'readUrl',
'unreadUrl',
//...
];
}
}
namespace common\models;
//...
class Message extends \bubasuma\simplechat\db\Message
{
/**
* @inheritDoc
*/
public function fields()
{
return [
//...
'text',
'date' => 'created_at',
//...
];
}
}
namespace frontend\controllers;
//...
use yii\web\Controller;
use common\models\Conversation;
use common\models\Message;
use bubasuma\simplechat\controllers\ControllerTrait;
//...
class MessageController extends Controller
{
use ControllerTrait;
/**
* @return string
*/
public function getMessageClass()
{
return Message::className();
}
/**
* @return string
*/
public function getConversationClass()
{
return Conversation::className();
}
}
# You can specify how many fixtures per user and message you need by the --users and --messages options
php yii simplechat/start --users=50 --messages=10000
php yii simplechat/reset --users=20 --messages=5000
# You can specify in what language to generate fixtures by the --language option. Thanks to yii2-faker
php yii simplechat/start --language="ru_RU"
php yii simplechat/reset --language="fr_FR"
php yii simplechat/start
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.