<?php


namespace frontend\modules\access\models;

use common\models\UserCardAccesses;
use frontend\modules\card\models\UserCard;
use Yii;

class Access extends \common\models\Accesses
{
    public function init()
    {
        parent::init();
    }

    public function afterSave($insert, $changedAttributes)
    {
        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub

        $user_card = UserCard::findOne(['id_user' => Yii::$app->user->identity->id]);
        $user_card_access = new UserCardAccesses();
        $user_card_access->user_card_id = $user_card->id;
        $user_card_access->accesses_id = $this->id;
        $user_card_access->save();
    }
}