🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 23:22:33 +01:00
parent 7f253b5261
commit 35202aa825
10 changed files with 49 additions and 26 deletions
+10 -9
View File
@@ -35,16 +35,14 @@ if (! function_exists('isDarkColor')) {
if (! function_exists('hasPermission')) {
function hasPermission(string $permission): bool
{
$value = app(PermissionsService::class)->getOrDefault($permission);
return $value === true || $value === 1 || $value === '1';
return app(PermissionsService::class)->getOrDefault($permission);
}
}
if (! function_exists('hasHousekeepingPermission')) {
function hasHousekeepingPermission(string $permission): bool
{
$value = app(HousekeepingPermissionsService::class)->getOrDefault($permission);
return $value === true || $value === 1 || $value === '1';
return app(HousekeepingPermissionsService::class)->getOrDefault($permission);
}
}
@@ -59,9 +57,11 @@ if (! function_exists('findMigration')) {
function findMigration(string $tableName): string
{
static $cache = [];
$cache = is_array($cache) ? $cache : [];
if (isset($cache[$tableName])) {
return $cache[$tableName];
$cached = $cache[$tableName];
return is_string($cached) ? $cached : '';
}
$migrationsPath = database_path('migrations');
@@ -75,8 +75,9 @@ if (! function_exists('findMigration')) {
if ($file->isFile() && $file->getExtension() === 'php') {
$content = @file_get_contents($file->getPathname());
if ($content !== false && str_contains($content, "Schema::create('$tableName'")) {
$cache[$tableName] = $file->getFilename();
return $file->getFilename();
$filename = (string) $file->getFilename();
$cache[$tableName] = $filename;
return $filename;
}
}
}
@@ -110,8 +111,8 @@ if (! function_exists('dropForeignKeyIfExists')) {
->pluck('CONSTRAINT_NAME');
foreach ($foreignKeys as $foreignKey) {
if (! empty($foreignKey)) {
$connection->statement("ALTER TABLE {$table} DROP FOREIGN KEY {$foreignKey}");
if (is_string($foreignKey) && $foreignKey !== '') {
$connection->statement('ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $foreignKey);
}
}
}