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

[9.x] Add news report_if and report_unless helpers functions #45093

Merged
merged 1 commit into from Nov 26, 2022

Conversation

michaelnabil230
Copy link
Contributor

This PR is to add the ability to report functions with some condition.

Ex:

class WelcomeController
{
    public function index(): View
    {
        if(! Auth::user()->isAdmin()){
            report('Is route need permission user');
        }
        
        // OR
         if(Auth::user()->isUser()){
            report('Is route need permission admin');
        }

        // Your code

        return view('welcome');
    }
}

After PR:

class WelcomeController
{
    public function index(): View
    {
        report_if(Auth::user()->isAdmin(), 'Is route need permission admin');
        
        // OR
        report_unless(Auth::user()->isAdmin(), 'Is route need permission user');

        // Your code

        return view('welcome');
    }
}

@michaelnabil230 michaelnabil230 changed the title Add news report_if and report_unless helpers functions [9.x] Add news report_if and report_unless helpers functions Nov 25, 2022
@taylorotwell taylorotwell merged commit 2071b04 into laravel:9.x Nov 26, 2022
@michaelnabil230 michaelnabil230 deleted the new-helpers branch November 26, 2022 18:04
bert-w pushed a commit to bert-w/framework that referenced this pull request Nov 28, 2022
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.

None yet

2 participants