Replace env() usage within app (#735)
env() will always return the default value when used outside of config files if the config has been cached
This commit is contained in:
parent
f77affb79e
commit
2558ee965c
|
|
@ -179,7 +179,7 @@ class Form extends Model implements CachableAttributes
|
||||||
public function getViewsCountAttribute()
|
public function getViewsCountAttribute()
|
||||||
{
|
{
|
||||||
return $this->remember('views_count', 15 * 60, function (): int {
|
return $this->remember('views_count', 15 * 60, function (): int {
|
||||||
if (env('DB_CONNECTION') == 'mysql') {
|
if (config('database.default') === 'mysql') {
|
||||||
return (int) ($this->views()->count() +
|
return (int) ($this->views()->count() +
|
||||||
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
|
$this->statistics()->sum(DB::raw("json_extract(data, '$.views')")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ class FormLogicConditionChecker
|
||||||
->where(function ($query) use ($condition, $fieldValue) {
|
->where(function ($query) use ($condition, $fieldValue) {
|
||||||
$fieldId = $condition['property_meta']['id'];
|
$fieldId = $condition['property_meta']['id'];
|
||||||
|
|
||||||
if (env('DB_CONNECTION') == 'mysql') {
|
if (config('database.default') === 'mysql') {
|
||||||
// For scalar values
|
// For scalar values
|
||||||
$query->where(function ($q) use ($fieldId, $fieldValue) {
|
$query->where(function ($q) use ($fieldId, $fieldValue) {
|
||||||
$q->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(data, '$.\"$fieldId\"')) = ?", [$fieldValue]);
|
$q->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(data, '$.\"$fieldId\"')) = ?", [$fieldValue]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue