Skip to content

Commit

Permalink
fix: Extension lower-uppercase support
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed May 9, 2024
1 parent c897166 commit f08333d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 5 additions & 10 deletions app/Http/Controllers/API/Settings/ExtensionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}'",
Expand Down Expand Up @@ -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')
Expand Down
10 changes: 10 additions & 0 deletions app/Models/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit f08333d

Please sign in to comment.