<?php

/**
 * @Author: 思睿软件
 * @Date:   2020-01-06 14:07:14
 * @Last Modified by:   xjx
 * @Last Modified time: 2020-01-14 09:39:37
 * 用户模型
 */

namespace siruisoft\common\model;

use siruisoft\common\model\ModelBase;

class Logs extends ModelBase
{
	protected $name='logs';

	protected $ctag ='logs';


	public  $types= ['1'=>'后台',0=>'前端'];


	/**
	 * [cleanLogs 清除days天前的记录]
	 * @Author   思睿软件
	 * @DateTime 2020-02-09T21:27:04+0800
	 * @Version  1.0
	 * @param    [type]                   $days [description]
	 * @return   [type]                      [description]
	 */
	public function cleanLogs($days)
		{
			$days = intval($days);
			if ($days <= 0) {
				return 0;
			}
			$before = strtotime("- {$days} days");
			try {
				$this->where(['ctime'=>['<=',$before]])->delete();
				return 1;
			} catch (Exception $e) {
				return 0;
			}
			
		}
}
