love_php/app/Models/HandleLogs.php
2026-04-02 09:20:51 +08:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class HandleLogs extends Model
{
//添加日志
public static function add($code = 1,$remark='',$data = [],$identifying=''){
try{
if(is_array($data)){
$data = json_encode($data,true);
}
if(is_array($remark)){
$remark = json_encode($remark,true);
}
if(is_array($identifying)){
$identifying = json_encode($identifying,true);
}
$HandleLogs = new HandleLogs();
$HandleLogs->code = $code;
$HandleLogs->data = $data;
$HandleLogs->remark = $remark;
$HandleLogs->identifying = $identifying;
$HandleLogs->save();
} catch (\Exception $e) {
\Log::info($e->getMessage());
}
}
/** 异常收集 */
public static function error($remark='',$identifying='',$data = [],$code = 2){
HandleLogs::add($code,$remark,$data,$identifying);
}
}