cập nhật tính năng quản trị phòng ban

This commit is contained in:
2020-10-07 17:29:30 +07:00
parent 586be80cf6
commit 2d15fc1c14
22 changed files with 1041 additions and 72 deletions

67
models/LogsDepartment.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "logs_department".
*
* @property int $id
* @property int $user_id
* @property int $time
* @property string $action
* @property string $description
*/
class LogsDepartment extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'logs_department';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['user_id', 'time', 'action', 'description'], 'required'],
[['user_id', 'time'], 'integer'],
[['description'], 'string'],
[['action'], 'string', 'max' => 10],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'user_id' => 'User ID',
'time' => 'Time',
'action' => 'Action',
'description' => 'Description',
];
}
public function create($data) {
$r = $this->load([
'user_id' => Yii::$app->user->id,
'time' => time(),
'action' => $data['action'],
'description' => $data['description']
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
}