$cid, 'name' => $name, 'path' => $path, 'type' => $type, 'mime' => $mime, 'size' => $size, 'storage' => $storage, ]; return self::create($data); } /** * 分页显示 * @param array $where * @return array * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function pagination(array $where): array { $model = (new Attachment)->where("type", $where['type']); if ($where['cid'] != "") $model = $model->where("cid", $where['cid']); $count = (new Attachment)->count(); $model = $model->order("id desc"); $model = $model->field("id,path"); $data = $model->page((int)$where['page'], (int)$where['limit'])->select(); if ($data) $data = $data->toArray(); return compact("data", "count"); } }