<?php

namespace App\Providers;

use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
use Illuminate\Support\ServiceProvider;

class LastModifiedServiceProvider extends ServiceProvider
{
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('lastModified', function () {
            return $this->getLastModifiedDate();
        });
    }

    protected function getLastModifiedDate()
    {
        date_default_timezone_set(config('app.timezone'));

        $timeStamp = null;

        $directories = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->app->basePath()));

        foreach ($directories as $path => $object) {
            if (basename($path) !== '.ftpquota' &&
                basename($path) !== 'DO_NOT_UPLOAD_HERE' &&
                basename($path) !== 'tmp') {
                $timeStamp = filemtime($path) > $timeStamp ? filemtime($path) : $timeStamp;
            }
        }

        return date('F jS, Y', $timeStamp).' at '.date('h:i:s A T', $timeStamp);
    }
}

<?php

namespace App\Providers;

use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
use Illuminate\Support\ServiceProvider;

class LastModifiedServiceProvider extends ServiceProvider
{
    /**
     * List of excluded directories when traversing application folders.
     *
     * @var array
     */
    private $excludedDirectories = [
        'vendor',
        'node_modules',
        'tmp',
        'storage',
        'tests',
        'cache',
    ];

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('lastModified', function () {
            return $this->getLastModifiedDate();
        });
    }

    /**
     * Function to get the last modified file time for the web application directory.
     *
     * @return string
     */
    protected function getLastModifiedDate()
    {
        date_default_timezone_set(config('app.timezone'));

        $timeStamp = null;

        $directories = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->app->basePath()));

        foreach ($directories as $path => $object) {
            if (! in_array(basename($path), $this->excludedDirectories, true)) {
                $timeStamp = filemtime($path) > $timeStamp ? filemtime($path) : $timeStamp;
            }
        }

        return date('F jS, Y', $timeStamp).' at '.date('h:i:s A T', $timeStamp);
    }
}

Create an array of directories to exclude
LatModifiedServiceProvider: Create an array of directories to exclude

when traversing the folder structure to get the last modified file time.