update Area + Device
This commit is contained in:
71
models/SystemLogs.php
Normal file
71
models/SystemLogs.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "system_logs".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $time
|
||||
* @property string $action
|
||||
* @property string $description
|
||||
* @property string $type
|
||||
*/
|
||||
class SystemLogs extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'system_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['user_id', 'time', 'action', 'description', 'type'], 'required'],
|
||||
[['user_id', 'time'], 'integer'],
|
||||
[['description'], 'string'],
|
||||
[['action'], 'string', 'max' => 10],
|
||||
[['type'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'user_id' => 'User ID',
|
||||
'time' => 'Time',
|
||||
'action' => 'Action',
|
||||
'description' => 'Description',
|
||||
'type' => 'Type',
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'user_id' => Yii::$app->user->id,
|
||||
'time' => time(),
|
||||
'action' => $data['action'],
|
||||
'description' => $data['description'],
|
||||
'type' => $data['type']
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user