From 0e155a0f5c33c0f75055c8a5c9f93baab94f84be Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 23 Jul 2016 21:43:42 +0800 Subject: [PATCH] fix missing argument when upload texture --- app/Controllers/SkinlibController.php | 2 +- app/Models/Closet.php | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/Controllers/SkinlibController.php b/app/Controllers/SkinlibController.php index b95f517c..8f13e46b 100644 --- a/app/Controllers/SkinlibController.php +++ b/app/Controllers/SkinlibController.php @@ -144,7 +144,7 @@ class SkinlibController extends BaseController $this->user->setScore($t->size, 'minus'); - if ($this->user->closet->add($t->tid)) { + if ($this->user->closet->add($t->tid, $t->name)) { $t = Texture::find($t->tid); $t->likes += 1; $t->save(); diff --git a/app/Models/Closet.php b/app/Models/Closet.php index 54f129f1..e4f2dcad 100644 --- a/app/Models/Closet.php +++ b/app/Models/Closet.php @@ -70,6 +70,10 @@ class Closet } unset($textures_invalid); + } else { + $this->eloquent_model = new ClosetModel(); + $this->eloquent_model->uid = $uid; + $this->eloquent_model->save(); } } @@ -85,11 +89,6 @@ class Closet return array_reverse(($category == "skin") ? $this->textures_skin : $this->textures_cape); } - public function getAmount() - { - return $this->eloquent_model->amount; - } - public function add($tid, $name) { foreach ($this->textures as $item) { @@ -103,7 +102,6 @@ class Closet 'add_at' => time() ); - $this->eloquent_model->amount += 1; $this->eloquent_model->textures = json_encode($this->textures); return $this->eloquent_model->save(); } @@ -133,7 +131,6 @@ class Closet foreach ($this->textures as $item) { if ($item['tid'] == $tid) { array_splice($this->textures, $offset, 1); - $this->eloquent_model->amount -= 1; $this->eloquent_model->textures = json_encode($this->textures); return $this->eloquent_model->save(); }