add rest application and discount-status rest method
This commit is contained in:
44
console/migrations/m180829_155430_add_rest_user.php
Normal file
44
console/migrations/m180829_155430_add_rest_user.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
use common\models\User;
|
||||
|
||||
class m180829_155430_add_rest_user extends Migration
|
||||
{
|
||||
/**
|
||||
* @return bool|void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$user = new User();
|
||||
$user->username = "discount_system";
|
||||
$user->email = "discount_system@rocho-net.hu";
|
||||
$user->setPassword("NmqFb\ivjtX1=yT*Aw5Y");
|
||||
$user->generateAuthKey();
|
||||
$user->save();
|
||||
|
||||
$role = Yii::$app->authManager->createRole('discount_system');
|
||||
Yii::$app->authManager->add($role);
|
||||
Yii::$app->authManager->assign($role, $user->id);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m180829_155430_add_rest_user cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user