From f08333d37ee511d1fc5695b3f91adc4b3a68ed9c Mon Sep 17 00:00:00 2001 From: dogukanoksuz Date: Thu, 9 May 2024 11:47:34 +0300 Subject: [PATCH] fix: Extension lower-uppercase support --- .../API/Settings/ExtensionController.php | 15 +++++---------- app/Models/Extension.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/API/Settings/ExtensionController.php b/app/Http/Controllers/API/Settings/ExtensionController.php index 4cb24f1a..6945cdff 100644 --- a/app/Http/Controllers/API/Settings/ExtensionController.php +++ b/app/Http/Controllers/API/Settings/ExtensionController.php @@ -140,6 +140,7 @@ public function upload() public function delete() { $ext_name = extension()->name; + $extension_id = extension()->id; try { Command::runLiman( "rm -rf '/liman/extensions/{:extension}'", @@ -167,17 +168,11 @@ public function delete() } catch (\Exception) { } - if (is_file(storage_path('extension_updates'))) { - $json = json_decode(file_get_contents(storage_path('extension_updates')), true); - for ($i = 0; $i < count($json); $i++) { - if ($json[$i]['name'] == $ext_name) { - unset($json[$i]); - } - } - file_put_contents(storage_path('extension_updates'), json_encode($json)); - } - try { + Permission::where('value', $extension_id) + ->where('type', 'extension') + ->delete(); + Permission::where('value', $ext_name) ->where('type', 'function') ->where('key', 'name') diff --git a/app/Models/Extension.php b/app/Models/Extension.php index f3048a91..314a67d8 100644 --- a/app/Models/Extension.php +++ b/app/Models/Extension.php @@ -131,6 +131,16 @@ public function getUpdatedAtAttribute($value) return \Carbon\Carbon::parse($value)->isoFormat('LLLL'); } + /** + * Get name attribute + * + * @return string + */ + public function getNameAttribute($value) + { + return strtolower($value); + } + /** * Set name attribute *