context->table('attachmentkeys')->insert([ 'attachment' => $attachmentid, ]); return $database->createModel('Attachmentkey', $activerow); } public static function retrieve(\App\Services\Database $database, $key) { $activerows = $database->context->table('attachmentkeys')->where('key', $key); foreach($activerows as $row) return $database->createModel('Attachmentkey', $row); return null; } public function getAttachment() { return $this->activerow->attachment; } public function getKey() { return $this->activerow->key; } public function delete() { return $this->activerow->delete(); } public function getUsed() { return $this->activerow->used; } public function setUsed($value=0) { $result = $this->activerow->update(['used' => $value]); return $result; } public function Increasedownloads() { $used = $this->getUsed() + 1; $this->activerow->update(['used' => $used]); return $used; } }