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);
    }