| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Models\Manager;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- /**
- * 后台管理员操作历史
- *
- */
- class AdminHistory extends Model
- {
- use HasFactory;
- // 与模型关联的表名
- protected $table = 'admin_history';
- // 定义时间戳字段名
- // const CREATED_AT = 'insert_time';
- // const UPDATED_AT = 'update_time';
- /**
- * 添加数据
- *
- * @param Int $uid 用户ID
- * @param String $table 操作表
- * @param Int $type 操作类型,1添加,2修改,3=删除
- * @param Array $oldData 旧数据
- * @param Array $oldData 新数据
- * @param String $general_description 操作描述
- *
- */
- public function addAll($admin_menu_name,$company_id='0', $uid, $is_admin, $table, $type, $oldData, $newData, $general_description = '')
- {
- $insert_data = [
- 'company_id' => $company_id,
- // 模块菜单名称
- 'module_menu_name' => $admin_menu_name,
- //操作描述
- 'general_description' => $general_description,
- // 操作类型
- 'notes_type' => $type,
- // 操作表名
- 'table_name' => $table,
- // 操作用户
- 'admin_uid' => $uid,
- // 是否是管理员
- 'is_admin' => $is_admin,
- // 操作之前
- 'before_value' => json_encode($oldData),
- // 操作之后
- 'after_value' => json_encode($newData),
- // 时间
- 'insert_time' => time(),
- ];
- // 结果
- $result = $this->insertGetId($insert_data);
- // 如果有数据
- return $result;
- }
- }
|