use Illuminate\Filesystem\Filesystem; $files = (new Filesystem)->allFiles(public_path());
use Illuminate\Filesystem\Filesystem; $files = (new Filesystem)->allFiles(public_path('uploads'), function($file) { return in_array($file->getExtension(), ['jpg', 'png', 'gif']); });
use Illuminate\Filesystem\Filesystem; $directories = ['public', 'app']; $files = []; foreach ($directories as $directory) { $files = array_merge($files, (new Filesystem)->allFiles(base_path($directory))); }This code will return an array of all files within the `public` and `app` directories, merged together into a single array. Overall, the `Illuminate\Filesystem\Filesystem` class provides a convenient way of working with files and directories in PHP, and is especially useful within the Laravel framework.