find(); if(empty($self)){ return []; } return $self->toArray(); } /** * @desc 获取文件路径 * @param $id * @return mixed|string * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getFilePath($id) { $self = self::where('id', $id)->find(); if(!empty($self)){ return $self->path; } return ''; } /** * @desc 将文件入库 * @param $path * @param int $type * @return int */ public static function insertFile($path, int $type = 1) { $self = new self; $self->type = $type; $self->path = $path; $self->create_time = date('Y-m-d H:i:s'); $self->save(); return $self->id; } }