<?php 
namespace app\common\model;
use think\Model;
use app\common\model\Jobs as JobsModel;
class JobsBrowse extends Model
{
	public static function saveBrowse($resume_id,$company_id,$id):void
	{
		if ($resume_id && $id){
			if (!self::where(['resume_id'=>$resume_id,'jobs_id'=>$id])->whereNull('delete_time')->count()) {
				$ResumeBrowseModel=new self;
				$ResumeBrowseModel->resume_id=$resume_id;
				$ResumeBrowseModel->company_id=$company_id;
				$ResumeBrowseModel->jobs_id=$id;
				$ResumeBrowseModel->save();
			}
		}
		self::setIncView($id);
	}
	public static function setIncView($id):void
	{
        $view_rand=intval(config('basic.view_rand'));
        $view=1;
        if ($view_rand)
        $view=rand(1,$view_rand);
		if ($id) JobsModel::where(['id'=>$id])->inc('view',$view)->update();
	}
}