src/Models/Website.php
public static function currentWebsiteData()
    {
        static $current_data;
        $BASE_URL  = static::currentServerName();
        $cache_key = 'website-data.' . $BASE_URL;

        // Get the current ID from the cache if it is present.
        if (empty($current_data)) {
            if (Cache::has($cache_key)) {
                return Cache::get($cache_key);
            }
        }

        // If the cache doesn't have it then get it from the database.
        if (empty($current_data)) {

            // Have to do this using a raw query because Laravel doesn't INSTR.
            try {
                /** @var Website $result */
                $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0")
                    ->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc')
                    ->first();
                if (empty($result)) {
                    $current_data = null;
                } else {
                    $current_data = $result->toArray();
                }

                Cache::put($cache_key, $current_data, 60);
            } catch (\Exception $e) {
                $current_data = null;
            }
        }

        return $current_data;
    }
public static function currentWebsiteData()
    {
        static $current_data;
        $BASE_URL  = static::currentServerName();
        $cache_key = 'website-data.' . $BASE_URL;

        // Get the current ID from the cache if it is present.
        if (empty($current_data)) {
            if (Cache::has($cache_key)) {
                return Cache::get($cache_key);
            }
        }

        // If the cache doesn't have it then get it from the database.
        if (empty($current_data)) {

            // Have to do this using a raw query because Laravel doesn't INSTR.
            try {
                /** @var Website $result */
                $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0")
                    ->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc')
                    ->first();
                if (empty($result)) {
                    $current_data = null;
                } else {
                    $current_data = $result->toArray();
                }

                Cache::put($cache_key, $current_data, 60);
            } catch (\Exception $e) {
                $current_data = null;
            }
        }

        return $current_data;
    }
public static function currentWebsiteData ( ) { static $ current_data ; $ BASE_URL = static :: currentServerName ( ) ; $ cache_key = 'website-data.' . $ BASE_URL ; // Get the current ID from the cache if it is present. if ( empty ( $ current_data ) ) { if ( Cache :: has ( $ cache_key ) ) { return Cache :: get ( $ cache_key ) ; } } // If the cache doesn't have it then get it from the database. if ( empty ( $ current_data ) ) { // Have to do this using a raw query because Laravel doesn't INSTR. try { /** @var Website $result */ $ result = static :: whereRaw ( "INSTR('" . $ BASE_URL . "', `http_host`) > 0" ) -> orderBy ( DB :: raw ( 'LENGTH(`http_host`)' ) , 'desc' ) -> first ( ) ; if ( empty ( $ result ) ) { $ current_data = null ; } else { $ current_data = $ result -> toArray ( ) ; } Cache :: put ( $ cache_key , $ current_data , 60 ) ; } catch ( \ Exception $ e ) { $ current_data = null ; } } return $ current_data ; }
Determine the current website data.

Returns null if the web site is not found in the websites table.

@return	array
Determine the current website data .