-
Notifications
You must be signed in to change notification settings - Fork 25
Reply Class Reference
The methods in the authManager
class all return instances of the Centaur\Replies\Reply
class, which is designed to be a general purpose data transfer object with a few Laravel niceties thrown in for good measure. There are three types of Reply
object:
-
Centaur\Replies\SuccessReply
- Returned when the requested action was accomplished successfully. -
Centaur\Replies\FailureReply
- Returned when the requested action failed. -
Centaur\Replies\ExceptionReply
- Returned if the requested action caught an exception.
The Reply
may contain a payload containing objects relevant to the requested action. Payload objects can be accessed through the __get()
magic method. For example, if the payload has a $user
, you can retrieve it like so: $user = $reply->user;
.
Returns: Boolean
Indicates whether the requested action was successful.
Returns: Boolean
Indicates whether the requested action failed.
Returns: Boolean
Indicates whether the requested value exists within the object. For example: $reply->has('message')
, $reply->has('user')
or $reply->has('exception')
Returns: void
Remove the requested value from the object if it exists.
Returns: void
Remove the entire payload from this object, whatever it may be.
Returns: void
Occasionally you may want to override the default redirect location in the dispatch()
method; this method lets you do that.
Returns: array
Convert the object to an array
Returns: string
Convert the object to a json string.
Returns: Illuminate\Http\RedirectResponse|Illuminate\Http\JsonResponse
A helper method for determining how a controller should respond to the authManager
results. It will automatically return json for ajax request, or redirects for http requests. Successful or failed replies will redirect to the specified $url
, whereas a reply that caught an exception will redirect to the previous url (unless you manually specify a different redirect location.)