This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @getProfileId | |
* | |
*/ | |
public function getProfileId() | |
{ | |
return $this->profile ? $this->profile->id : 'none'; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace common\models; | |
use Yii; | |
use yii\base\NotSupportedException; | |
use yii\db\ActiveRecord; | |
use yii\db\Expression; | |
use yii\web\IdentityInterface; | |
use yii\helpers\Security; | |
use backend\models\Role; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get user id Link | |
* | |
*/ | |
public function getUserIdLink() | |
{ | |
$url = Url::to(['user/update', 'id'=>$this->id]); | |
$options = []; | |
return Html::a($this->id, $url, $options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Your model attribute labels */ | |
public function attributeLabels() | |
{ | |
return [ | |
/* Your other attribute labels */ | |
'roleName' => Yii::t('app', 'Role'), | |
'statusName' => Yii::t('app', 'Status'), | |
'profileId' => Yii::t('app', 'Profile'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* behaviors | |
*/ | |
public function behaviors() | |
{ | |
return [ | |
'timestamp' => [ | |
'class' => 'yii\behaviors\TimestampBehavior', | |
'attributes' => [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace common\models; | |
class ValueHelpers | |
{ | |
/** | |
* return the value of a role name handed in as string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace common\models; | |
use common\models\ValueHelpers; | |
use yii; | |
use yii\web\Controller; | |
use yii\helpers\Url; | |
class PermissionHelpers | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace common\models; | |
use yii; | |
class RecordHelpers | |
{ | |
public static function userHas($model_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function loginAdmin() | |
{ | |
if (($this->validate()) && $this->getUser()->role_id >= ValueHelpers::getRoleValue('Admin') | |
&& $this->getUser()->status_id == ValueHelpers::getStatusValue('Active')) { | |
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); | |
} else { | |
throw new NotFoundHttpException('You Shall Not Pass.'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function login() | |
{ | |
if ($this->validate() && $this->getUser()->status_id == ValueHelpers::getStatusValue('Active')) { | |
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); | |
} else { | |
return false; | |
} |