Fix orderByProcess() input being null

Fix orderByProcess() input being null by having the input be 2 if the settings values via the session havent  been set
This commit is contained in:
cp6 2022-10-31 11:14:26 +11:00
parent 1c8ec5fc6b
commit 10e2d7dbba
5 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@ class Misc extends Model
parent::boot(); parent::boot();
static::addGlobalScope('order', function (Builder $builder) { static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on')); $array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]); $builder->orderBy($array[0], $array[1]);
} }

View File

@ -26,7 +26,7 @@ class Reseller extends Model
parent::boot(); parent::boot();
static::addGlobalScope('order', function (Builder $builder) { static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on')); $array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]); $builder->orderBy($array[0], $array[1]);
} }

View File

@ -26,7 +26,7 @@ class SeedBoxes extends Model
parent::boot(); parent::boot();
static::addGlobalScope('order', function (Builder $builder) { static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on')); $array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]); $builder->orderBy($array[0], $array[1]);
} }

View File

@ -33,7 +33,7 @@ class Server extends Model
parent::boot(); parent::boot();
static::addGlobalScope('order', function (Builder $builder) { static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on')); $array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]); $builder->orderBy($array[0], $array[1]);
} }

View File

@ -26,7 +26,7 @@ class Shared extends Model
parent::boot(); parent::boot();
static::addGlobalScope('order', function (Builder $builder) { static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on')); $array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]); $builder->orderBy($array[0], $array[1]);
} }