UpdateLog.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Models\Com;
use Illuminate\Database\Eloquent\Model;
class UpdateLog extends Model
{
//设置关联表名
protected $table = 'gl_update_log';
const STATUS_UN = 0;//未开始
const STATUS_ING = 1;//导入中
const STATUS_COM = 2;//导入完成
const COLLECT_STATUS_UN = 0;//未开始
const COLLECT_STATUS_COM = 1;//采集完成
/**
* 创建更新日志
* @param $project_id
* @param $type
* @param $url
* @param $sort
* @return mixed
*/
public static function createLog($project_id, $type, $url)
{
$log = self::where('project_id', $project_id)->where('api_type', $type)->first();
if (!$log) {
$log = new self();
$log->project_id = $project_id;
$log->api_type = $type;
$log->api_url = $url;
$log->sort = $type == 'category' ? 0 :1;
$log->collect_status = in_array($type, ['website_info', 'category']) ? 1 : 0;
return $log->save();
}
return true;
}
}