-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Simplify conditionals in ExtensionController and Helpers.php
Simplified the conditionals in ExtensionController and Helpers.php to use boolean values instead of string comparisons. This improves readability and maintainability of the code.
- Loading branch information
1 parent
c4646c8
commit 45afe73
Showing
9 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
database/migrations/2024_10_17_150509_alter_table_extensions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Support\Str; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('extensions', function (Blueprint $table) { | ||
$table->dropColumn('status'); | ||
$table->dropColumn('displays'); | ||
$table->dropColumn('support'); | ||
$table->dropColumn('language'); | ||
$table->dropColumn('issuer'); | ||
$table->dropColumn('service'); | ||
$table->dropColumn('order'); | ||
// require_key defaults to false | ||
// first convert existing data to boolean | ||
DB::statement("ALTER TABLE extensions | ||
ALTER COLUMN require_key DROP DEFAULT, | ||
ALTER COLUMN require_key TYPE BOOLEAN USING require_key::BOOLEAN, | ||
ALTER COLUMN require_key SET DEFAULT FALSE;"); | ||
// add version_code column | ||
$table->string('version_code')->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// | ||
} | ||
}; |
32 changes: 32 additions & 0 deletions
32
database/migrations/2024_10_17_153851_fill_version_code_column_on_table_extensions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
$extensions = \App\Models\Extension::all(); | ||
foreach ($extensions as $extension) { | ||
$extJson = getExtensionJson($extension->name); | ||
if (!$extJson) { | ||
continue; | ||
} | ||
$extension->version_code = $extJson['version_code']; | ||
$extension->save(); | ||
} | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// | ||
} | ||
}; |