Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hidden property #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

TanisukeGoro
Copy link
Owner

@TanisukeGoro TanisukeGoro commented Jun 17, 2023

usage

<?php

declare(strict_types=1);

namespace App\Enums;

use BenSampo\Enum\Enum;
use BenSampo\Enum\Contracts\LocalizedEnum;

/**
 * @method static static Administrator()
 * @method static static Moderator()
 * @method static static Subscriber()
 * @method static static SuperAdministrator()
 *
 * @extends Enum<string>
 */
final class UserType extends Enum implements LocalizedEnum
{
    public const Administrator = 'administrator';
    public const Moderator = 'moderator';
    public const Subscriber = 'subscriber';
    public const SuperAdministrator = 'super_administrator';

    // add hidden property
    protected $hidden = [
        self::Moderator,
        self::Subscriber
    ];
}
# before
UserType::asSelectArray()
array:4 [
    "administrator" => "administrator description",
    "moderator" => "moderator description",
    "subscriber" => "subscriber description",
    "super_administrator" => "super administrator description",
  ]
(※ ↑ assuming the description is defined in enums.php)

# after
GlobalStatusType::asSelectArray();
array:4 [
    "administrator" => "administrator description",
    "super_administrator" => "super administrator description",
]

next action

  • create makeVisible method
  • create makeHidden method
  • Added or updated tests
  • Added or updated the README.md
  • Detailed changes in the CHANGELOG.md unreleased section

Related Issue/Intent

Changes

Breaking changes

next action

- [] create makeVisible method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant