You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Fix code in somephp files an refactored and deleted deprecated code 🆙
This commit is contained in:
@@ -37,12 +37,33 @@ if (! function_exists('strLimit')) {
|
||||
if (! function_exists('findMigration')) {
|
||||
function findMigration(string $tableName): string
|
||||
{
|
||||
foreach (glob(database_path('migrations/*.php')) as $filename) {
|
||||
$content = file_get_contents($filename);
|
||||
if ($content !== false && str_contains($content, "Schema::create('$tableName'")) {
|
||||
return basename($filename);
|
||||
}
|
||||
static $cache = [];
|
||||
|
||||
if (isset($cache[$tableName])) {
|
||||
return $cache[$tableName];
|
||||
}
|
||||
|
||||
$migrationsPath = database_path('migrations');
|
||||
if (! is_dir($migrationsPath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
$files = new \DirectoryIterator($migrationsPath);
|
||||
foreach ($files as $file) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error("Error finding migration for table {$tableName}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
$cache[$tableName] = '';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user