Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
michaelnabil230:new-helpers
Nov 26, 2022
Merged

[9.x] Add news report_if and report_unless helpers functions#45093
taylorotwell merged 1 commit into
laravel:9.xfrom
michaelnabil230:new-helpers

Conversation

@michaelnabil230
Copy link
Copy Markdown
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
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.

2 participants