diff --git a/src/Commands/FindCommand.php b/src/Commands/FindCommand.php index 73cad05..9c5577b 100644 --- a/src/Commands/FindCommand.php +++ b/src/Commands/FindCommand.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Support\Arr; use Themsaid\Langman\Manager; -use Illuminate\Support\Str; class FindCommand extends Command { diff --git a/src/Manager.php b/src/Manager.php index 4ff5824..f02a078 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -58,20 +58,21 @@ public function files() }); $filesByFile = $files->groupBy(function ($file) { - $fileName = $file->getBasename('.'.$file->getExtension()); + $filePath = str_replace('.' . $file->getExtension(), '', $file->getRelativePathname()); + $filePath = array_reverse(explode('/', $filePath, 2))[0]; if (Str::contains($file->getPath(), 'vendor')) { - $fileName = str_replace('.php', '', $file->getFileName()); + $filePath = str_replace('.php', '', $file->getFileName()); $packageName = basename(dirname($file->getPath())); - return "{$packageName}::{$fileName}"; + return "{$packageName}::{$filePath}"; } else { - return $fileName; + return $filePath; } })->map(function ($files) { return $files->keyBy(function ($file) { - return basename($file->getPath()); + return explode('/', str_replace($this->path, '', $file->getRelativePathname()))[0]; })->map(function ($file) { return $file->getRealPath(); });