<commit_before><?php
namespace models;

/**
 * AppConfig
 *
 * @author <NAME> <<EMAIL>>
 */
class AppConfig extends \Core\Model
{
	protected $guarded = array();
	protected $primaryKey = '_id';

	public function app() {
		return $this->belongsTo('models\App');
	}

	/**
	 * Get app config value by name
	 * @param string name
	 * @param string default
	 * @return string
	 */
	public static function get($name, $default = null) {
		$config = static::current()->where('name', $name)->first();
		return ($config) ? $config->value : $default;
	}

	/**
	 * Get app configs by pattern
	 * @param string pattern
	 * @return Illuminate\Support\Collection
	 */
	public static function getAll($pattern) {
		return static::current()->where('name', 'like', $pattern)->get();
	}

	/**
	 * Current app scope
	 * @example
	 *     AppConfig::current()->where('name', 'like', 'mail.%')->get()
	 */
	public function scopeCurrent($query) {
		return $query->where('app_id', App::currentId());
	}

}<commit_msg>appconfig now returns correct config for individual apps<commit_after><?php
namespace models;

/**
 * AppConfig
 *
 * @author <NAME> <<EMAIL>>
 */
class AppConfig extends \Core\Model
{
	protected $guarded = array();
	protected $primaryKey = '_id';

	public function app() {
		return $this->belongsTo('models\App');
	}

	/**
	 * Get app config value by name
	 * @param string name
	 * @param string default
	 * @return string
	 */
	public static function get($name, $default = null) {
		$config = static::scopeCurrent()->where('name', $name)->first();
		return ($config) ? $config->value : $default;
	}

	/**
	 * Get app configs by pattern
	 * @param string pattern
	 * @return Illuminate\Support\Collection
	 */
	public static function getAll($pattern) {
		return static::scopeCurrent()->where('name', 'like', $pattern)->get();
	}

	/**
	 * Current app scope
	 * @example
	 *     AppConfig::current()->where('name', 'like', 'mail.%')->get()
	 */
	public function static scopeCurrent() {
		return static::current()->where('app_id', App::currentId());
	}

}
{'fraction_non_alphanumeric': 0.17995110024449879, 'fraction_numerical': 0.0, 'mean_word_length': 3.953995157384988, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4123289', 'n_tokens_mistral': 655, 'n_tokens_neox': 613, 'n_words': 168}