Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yiier/yii2-invite-code
Invite Code for Yii2 (邀请码)
https://github.com/yiier/yii2-invite-code
yii yii2-extension
Last synced: 14 days ago
JSON representation
Invite Code for Yii2 (邀请码)
- Host: GitHub
- URL: https://github.com/yiier/yii2-invite-code
- Owner: yiier
- License: bsd-3-clause
- Created: 2016-04-27T10:39:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-11T00:18:04.000Z (about 8 years ago)
- Last Synced: 2024-04-14T09:58:38.114Z (8 months ago)
- Topics: yii, yii2-extension
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
invite code for Yii2
====================[![Latest Stable Version](https://poser.pugx.org/yiier/yii2-invite-code/v/stable)](https://packagist.org/packages/yiier/yii2-invite-code)
[![Total Downloads](https://poser.pugx.org/yiier/yii2-invite-code/downloads)](https://packagist.org/packages/yiier/yii2-invite-code)
[![Latest Unstable Version](https://poser.pugx.org/yiier/yii2-invite-code/v/unstable)](https://packagist.org/packages/yiier/yii2-invite-code)
[![License](https://poser.pugx.org/yiier/yii2-invite-code/license)](https://packagist.org/packages/yiier/yii2-invite-code)invite code for Yii2
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist yiier/yii2-invite-code "*"
```or add
```
"yiier/yii2-invite-code": "*"
```to the require section of your `composer.json` file.
Usage
-----**mirage database**
```
$ php yii migrate --migrationPath=@yiier/inviteCode/migrations/
```**change config**
change `console\config\main.php````php
'params' => $params,
...
'controllerMap' => [
'gcode' => [
'class' => 'yiier\inviteCode\GCodeController',
]
]
```**console**
```
$ php yii gcode 200
```or
```
$ php yii gcode
```**change form view `signup.php`**
```php
// ...
= $form->field($model, 'password')->passwordInput() ?>= $form->field($model, 'inviteCode')->textInput() ?>
// ...
```**change `SignupForm.php`**
```php
// ...
public $inviteCode;// ...
public function rules()
{
return [
// ...
['inviteCode', 'required'],
['inviteCode', 'yiier\inviteCode\CodeValidator'],
];
}// ...
public function signup()
{
// ...
// return $user->save() ? $user : null;
// after change
if ($user->save()) {
InviteCode::useCode($this->inviteCode, $user->id);
return $user;
}
return null;
}
```