return response (json) and abort

Posted 1 year ago by jaheller

I'm using a function like this:

function validateData(){

        //logic here...
        if($a== $b){
                return response()->json(
                    [
                        'errors' => 
                        [
                            'message_detail'        => 'x',
                        ],
                    ]
                );

        }
        else{
                return response()->json(
                    [
                        'errors' => 
                        [
                            'message_detail'        => 'y',
                        ],
                    ]
                );

        }
}


//inside my controller

//...
$this->validateData();
dd("here");

Now the dd() function is executed too. How to prevent this? Is there a more elegant way then using simple a simple "die();" inside the first function?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.