43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class HandeDoLog extends BaseModel
|
|
{
|
|
//
|
|
public static function insertLog($model_type,$model_id,$do_value,$data,$is_admin=1){
|
|
$data=[
|
|
'model_type'=>$model_type,
|
|
'model_id'=>$model_id,
|
|
'do_value'=>$do_value,
|
|
'data'=>$data,
|
|
'created_at'=>date('Y-m-d H:i:s')
|
|
];
|
|
if($is_admin)
|
|
{
|
|
$data['do_name']=admin('realname');
|
|
$data['do_type']='admin';
|
|
$data['do_id']=admin('id');
|
|
}else
|
|
{
|
|
$data['do_name']=merchant('realname');
|
|
$data['do_type']='merchant';
|
|
$data['do_id']=merchant('id');
|
|
}
|
|
$r= self::create($data);
|
|
return $r;
|
|
}
|
|
public static function getLastLog($model_type,$model_id){
|
|
//取得最后一个日志
|
|
$last=self::where(['model_type'=>$model_type,'model_id'=>$model_id])->orderBy('id','desc')->first();
|
|
|
|
if($last)
|
|
{
|
|
return $last->toArray();
|
|
}
|
|
return [];
|
|
}
|
|
}
|