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

Get the first message #29

Closed
MrSam opened this issue May 31, 2017 · 0 comments
Closed

Get the first message #29

MrSam opened this issue May 31, 2017 · 0 comments

Comments

@MrSam
Copy link

MrSam commented May 31, 2017

Very often you would only need one message of a certain key ; or you know 100% there is only one. If that is the case its mega overhead to be doing array looping/checking in your display code.

Can we introduce something like this?

class V6Messages extends \Slim\Flash\Messages {
    public function getFirstMessage($key) {
        $messages = self::getMessage($key);
        if(is_array($messages) && count($messages)>0) {
            return $messages[0];
        }

        return null;
    }
}

After that you can just use

{{$messages->getFirstMessage('key')}}

in your template code nice and clean.

akrabat added a commit to akrabat/Slim-Flash that referenced this issue Oct 22, 2017
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

No branches or pull requests

1 participant