🎨 改进结构和代码格式

This commit is contained in:
WispX
2020-03-07 14:44:02 +08:00
parent c44e9d266d
commit a8cf1aab4e
2 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -38,4 +38,4 @@ class Images extends Model
{
return format_time($data['create_time']);
}
}
}
+10 -7
View File
@@ -20,6 +20,7 @@ class User extends Base
{
public function images($keyword = '', $folderId = 0, $limit = 60)
{
$images = $folders = [];
if ($this->request->isPost()) {
try {
$model = $this->user->images()->order('create_time', 'desc');
@@ -30,11 +31,7 @@ class User extends Base
if (is_numeric($folderId)) {
$model = $model->where('folder_id', $folderId);
}
$images = $model->paginate($limit)->each(function ($item) {
$item->url = $item->url;
// TODO 生成缩略图
return $item;
});
$images = $model->paginate($limit);
} catch (Exception $e) {
$this->error($e->getMessage());
}
@@ -97,9 +94,15 @@ class User extends Base
Db::commit();
} catch (Exception $e) {
Db::rollback();
return $deleteId ? false : $this->error($e->getMessage());
if ($deleteId) {
return false;
}
$this->error($e->getMessage());
}
return $deleteId ? true : $this->success('删除成功');
if ($deleteId) {
return true;
}
$this->success('删除成功');
}
public function createFolder()