示例#1
0
 /**
  * Finds the UserLogin model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Log the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Log::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Log::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('user');
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'login_at' => $this->login_at]);
     $query->andFilterWhere(['like', 'data', $this->data]);
     $query->andFilterWhere(['like', 'user.name', $this->user_id]);
     return $dataProvider;
 }
示例#3
0
文件: index.php 项目: kvazarum/prereg
use common\models\User;
use frontend\modules\log\models\Log;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\UserLoginSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'User Logs';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-login-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'user_id', 'format' => 'raw', 'value' => function ($model) {
    $user = User::findOne($model->user_id);
    return Html::a($user->name, '/user/view?id=' . $model->user_id, ['target' => '_blank']);
}], ['attribute' => 'action', 'value' => function ($model) {
    return Log::getActionName($model->action);
}], ['attribute' => 'login_at', 'value' => function ($model) {
    return date('d-m-Y H:i:s', $model->login_at);
}], 'data:ntext', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
示例#4
0
文件: User.php 项目: kvazarum/prereg
 public function afterDelete()
 {
     $data = Json::encode(['ID' => $this->id, 'name' => $this->name]);
     Log::addLog(Log::ACTION_DELETE_USER, $data);
     parent::afterDelete();
 }
示例#5
0
 public function afterDelete()
 {
     $data = Json::encode(['ID' => $this->id, 'name' => $this->doctor->name, 'occupation' => $this->occupation->name]);
     Log::addLog(Log::ACTION_DELETE_SPECIALIST, $data);
     parent::afterDelete();
 }