Add blacklist support to base NameValue class, for hiding options when getting entire collection #800
This commit is contained in:
parent
d52402a2ef
commit
be0e69db89
2 changed files with 22 additions and 1 deletions
|
|
@ -29,4 +29,8 @@ class JORejectionReason extends NameValue
|
||||||
'no_credit_card' => 'NO CREDIT CARD PAYMENT / NO TERMINAL',
|
'no_credit_card' => 'NO CREDIT CARD PAYMENT / NO TERMINAL',
|
||||||
'discount' => 'DISCOUNT',
|
'discount' => 'DISCOUNT',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const BLACKLIST = [
|
||||||
|
self::ADMINISTRATIVE => true,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,21 @@ namespace App\Ramcar;
|
||||||
|
|
||||||
class NameValue
|
class NameValue
|
||||||
{
|
{
|
||||||
|
const BLACKLIST = [];
|
||||||
|
|
||||||
static public function getCollection()
|
static public function getCollection()
|
||||||
{
|
{
|
||||||
return static::COLLECTION;
|
$result = [];
|
||||||
|
$blacklist = static::getBlacklist();
|
||||||
|
|
||||||
|
// filter from blacklist
|
||||||
|
foreach(static::COLLECTION as $key => $row) {
|
||||||
|
if (!isset($blacklist[$key])) {
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function validate($value)
|
static public function validate($value)
|
||||||
|
|
@ -24,4 +36,9 @@ class NameValue
|
||||||
|
|
||||||
return 'Unknown';
|
return 'Unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function getBlacklist()
|
||||||
|
{
|
||||||
|
return static::BLACKLIST ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue