| Current Path : /var/www/html/hr/models/ |
| Current File : /var/www/html/hr/models/Log.php |
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "log".
*
* @property int $id
* @property int $user_id
* @property int $menu_id
* @property string $action_type
* @property string $data_uuid
* @property string $action_datetime
*/
class Log extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'log';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['user_id', 'menu_id'], 'integer'],
[['action_datetime'], 'safe'],
[['action_type'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'user_id' => 'User ID',
'menu_id' => 'Menu ID',
'action_type' => 'Action Type',
'data_uuid' => 'Data Uuid',
'action_datetime' => 'Action Datetime',
];
}
public function insertlog($menu_id, $action_type, $data_uuid) {
$model = new Log();
$model->user_id = Yii::$app->user->identity->id;
$model->action_datetime = date("Y-m-d H:i:s");
$model->menu_id = $menu_id;
$model->action_type = $action_type;
$model->data_uuid = $data_uuid;
$model->save();
}
public function gettypedesc($type) {
$output = '';
if ($type == 'create')
$output = 'created';
if ($type == 'update')
$output = 'updated';
if ($type == 'status0')
$output = 'change status to inactive';
if ($type == 'status1')
$output = 'change status to active';
if ($type == 'delete')
$output = 'deleted';
return $output;
}
}