src/Models/Config.php
public static function fetchSettings($environment = null, $website_id = null, $group = 'config')
    {
        $model = static::where('group', '=', $group);

        // Environment can be null, or must match or use the null wildcard.
        $model->where(function ($query) use ($environment) {
            if (empty($environment)) {
                $query->whereNull('environment');
            } else {
                $query->where('environment', '=', $environment)
                    ->orWhereNull('environment');
            }
        });

        // Website can be null, or must match or use the null wildcard.
        $model->where(function ($query) use ($website_id) {
            if (empty($website_id)) {
                $query->whereNull('website_id');
            } else {
                $query->where('website_id', '=', $website_id)
                    ->orWhereNull('website_id');
            }
        });

        // Order by relevance.
        $model->orderBy(DB::raw('CASE
            WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1
            WHEN website_id IS NOT NULL THEN 2
            WHEN environment IS NOT NULL THEN 3
            ELSE 4
        END'));

        /*
        Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            'Config SQL query: ' . $model->toSql());
        */

        /** @var Collection $collection */
        $collection = $model->get();
        return static::normaliseCollection($collection);
    }
public static function fetchSettings($environment = null, $website_id = null, $group = 'config')
    {
        $model = static::where('group', '=', $group);

        // Environment can be null, or must match or use the null wildcard.
        $model->where(function ($query) use ($environment) {
            if (empty($environment)) {
                $query->whereNull('environment');
            } else {
                $query->where('environment', '=', $environment)
                    ->orWhereNull('environment');
            }
        });

        // Website can be null, or must match or use the null wildcard.
        $model->where(function ($query) use ($website_id) {
            if (empty($website_id)) {
                $query->whereNull('website_id');
            } else {
                $query->where('website_id', '=', $website_id)
                    ->orWhereNull('website_id');
            }
        });

        // Order by relevance.
        $model->orderBy(DB::raw('CASE
            WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1
            WHEN website_id IS NOT NULL THEN 2
            WHEN environment IS NOT NULL THEN 3
            ELSE 4
        END'));

        /*
        Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            'Config SQL query: ' . $model->toSql());
        */

        /** @var Collection $collection */
        $collection = $model->get();
        return static::normaliseCollection($collection);
    }
public static function fetchSettings ( $ environment = null , $ website_id = null , $ group = 'config' ) { $ model = static :: where ( 'group' , '=' , $ group ) ; // Environment can be null, or must match or use the null wildcard. $ model -> where ( function ( $ query ) use ( $ environment ) { if ( empty ( $ environment ) ) { $ query -> whereNull ( 'environment' ) ; } else { $ query -> where ( 'environment' , '=' , $ environment ) -> orWhereNull ( 'environment' ) ; } } ) ; // Website can be null, or must match or use the null wildcard. $ model -> where ( function ( $ query ) use ( $ website_id ) { if ( empty ( $ website_id ) ) { $ query -> whereNull ( 'website_id' ) ; } else { $ query -> where ( 'website_id' , '=' , $ website_id ) -> orWhereNull ( 'website_id' ) ; } } ) ; // Order by relevance. $ model -> orderBy ( DB :: raw ( 'CASE
            WHEN website_id IS NOT NULL AND environment IS NOT NULL THEN 1
            WHEN website_id IS NOT NULL THEN 2
            WHEN environment IS NOT NULL THEN 3
            ELSE 4
        END' ) ) ; /*
        Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
            'Config SQL query: ' . $model->toSql());
        */ /** @var Collection $collection */ $ collection = $ model -> get ( ) ; return static :: normaliseCollection ( $ collection ) ; }
Return the configuration data for a specific environment & group.

What this function tries to achieve is to return the configuration
for a given environment and group,  The configuration table contains
2 limiting columns, which are website_id and environment.  The way
that the limiting columns work is that if there is an entry in that
column then that config item applies only for that host or environment.
If a config item is sought where the host or environment matches then
these limited values take precedence over any values where website_id
or environment are NULL.

Otherwise the values that are stored where website_id and/or environment
act as "wildcards", so that they will match any searched website_id
or environment if there is no closer match.

As an example here are some table entries:

<code>
id     site    env    key    value
1      NULL    NULL   fruit  apple
2      NULL    prod   fruit  banana
3      www     prod   fruit  mango
4      NULL    test   fruit  peach
5      test    NULL   fruit  orange
</code>

Given that sample data, this function should return the following
data for these searches:

<code>
env     host   key    data returned
NULL    NULL   fruit  1, fruit, apple
prod    NULL   fruit  2, fruit, banana
NULL    www    fruit  3, fruit, mango
junk    junk   fruit  1, fruit, apple  // NULL/NULL values are used as a fallback
junk    www    fruit  1, fruit, apple  // no match, fallback
prod    test   fruit  5, fruit, orange // host=test takes precedence
</code>

The data that this function returns is actually a set of key => value
pairs for the configuration found within group $group.

To get the full configuration you need to call this function for each
group returned by fetchAllGroups().

@param string $environment
@param integer $website_id
@param string $group
@return array
Return the configuration data for a specific environment & group .