auto属性自动完成包含新增和更新操作
namespace app\index\model;
use think\Model;
class User extends Model
{
protected $auto = ['email'=>'thinkphp@qq.com','ip']; public function setIpAttr(){
return request() -> ip();
}
}
// 系统会自动将email写入 thinkphp@qq.com , ip 自动写入当前的 系统的ip地址(例如 127.0.0.1)