Using Laravel 5, I want to send a custom abort()
message.
For example, if the user doesn't have the required permissions for an action,
I'd like to abort(401, "User can't perform this actions")
.
Currently, when I do so, the response text is HTML page and not the message.
How can I return only the message?
Note: I don't want to pass a different view, but only the custom message.
abort($code, $message)
(provided$request->wantsJson()
). – Haphazard