Пример #1
0
 public static function getAuthItemParent($child)
 {
     $res = AuthItemChild::find()->where(['child' => $child])->one();
     if ($res) {
         return $res['parent'];
     } else {
         return null;
     }
 }
Пример #2
0
 /**
  * Finds the AuthItemChild model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $parent
  * @param string $child
  * @return AuthItemChild the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($parent, $child)
 {
     if (($model = AuthItemChild::findOne(['parent' => $parent, 'child' => $child])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItemChildren0()
 {
     return $this->hasMany(AuthItemChild::className(), ['child' => 'name']);
 }
Пример #4
0
?>

</div>

<!-- <span class="label label-default">Default</span>
<span class="label label-primary">Primary</span>
<span class="label label-success">Success</span>
<span class="label label-info">Info</span>
<span class="label label-warning">Warning</span>
<span class="label label-danger">Danger</span> -->

<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">Roles</h3>
  </div>
  <div class="panel-body">
  <?php 
$lbl = ['default', 'primary', 'success', 'info'];
$roles = \backend\models\AuthItemChild::findAll(['parent' => $model->name]);
// print_r($roles);
// exit();
foreach ($roles as $k => $v) {
    $rn = rand(0, 3);
    // echo $v;
    // echo $v['child'];
    echo "<span style=\"margin:5px\" class=\"label label-{$lbl[$rn]}\">{$v['child']}</span>";
}
?>
  </div>
</div>