Beispiel #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.');
     }
 }
Beispiel #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;
 }
Beispiel #3
0
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>
Beispiel #4
0
 public function afterDelete()
 {
     $data = Json::encode(['ID' => $this->id, 'name' => $this->name]);
     Log::addLog(Log::ACTION_DELETE_USER, $data);
     parent::afterDelete();
 }
Beispiel #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();
 }