/** * Check if given tid is valid. * * @param int $tid * @return bool */ private function checkTextureExist($tid) { return !Texture::where('tid', $tid)->isEmpty(); }
public function delete(Request $request) { $result = Texture::find($request->tid); if (!$result) { return json(trans('skinlib.non-existent'), 1); } if ($result->uploader != $this->user->uid && !$this->user->isAdmin()) { return json(trans('skinlib.no-permission'), 1); } // check if file occupied if (Texture::where('hash', $result['hash'])->count() == 1) { Storage::delete($result['hash']); } if (option('return_score')) { $this->user->setScore($result->size * Option::get('score_per_storage'), 'plus'); } if ($result->delete()) { return json(trans('skinlib.delete.success'), 0); } }