request.all()// Returns an object containing all request data (merges query params and request body data).
request.get()// Returns an object containing query params data.
request.post()// Returns an object containing request body data.
request.raw()// Returns raw body data as a string.
request.only(['username','age'])// Returns an object with only the specified keys.
request.collect(['username','age'])// Formats so it’s ready to save to the database.
request.except(['csrf_token','submit'])// Returns an object with everything except the specified keys (opposite of only).
request.input('drink','coffee')// Get the value of a given key (if it doesn’t exist, return the default value).
request.headers()// Returns an object of all header data.
request.header('some-other-header','default')// The header value for a given key (optionally with default value).
request.cookies()// Returns an object of all cookie data.
request.cookie('cart_total',0)// Returns the cookie value for a given key (optionally with default value).
request.plainCookies()// Returns an object of all raw cookie data.
request.plainCookie('cart_total',0)// Returns the raw cookie value for a given key (optionally with default value).
request.accepts(['json','html'])// Reads the Accept header to help determine the response format.
request.language(['en','fr'])// Language can also be negotiated based upon the Accept-Language header.
request.url()// Returns the current request url.
request.originalUrl()// Returns the full current request url with query strings.
request.method()// Returns the HTTP request method.
request.intended()// Returns the intended request HTTP method.
request.ip()// Returns the most trusted ip address for the user.
request.ips()// Returns an array of ips from most to the least trusted (removes the default ip address, which can be accessed via the ip method).
request.subdomains()// Returns a list of request subdomains (removes www from the list).
request.ajax()// Checks for X-Requested-With header to determine if the request is ajax or not.
request.pjax()// This methods looks for the X-PJAX header to identify if a request is pjax or not.
request.hostname()// Returns the request hostname.
request.protocol()// Return the request protocol.
request.match(['posts/:id'])// Returns whether the passed set of expressions match the current request URL.
request.hasBody()// A boolean indicating if the request has a post body (mainly used by the BodyParser to determine whether or not to parse the body).
request.is(['json','html'])// The is method returns the best matching content type for the current request. The check is entirely based upon the content-type header.
above// Makes sure the value provided by the end user is above the expected value.
accepted// Ensures that the field under validation is accepted.
after// Ensures the value of the field is after the expected date.
afterOffsetOf// Ensures the date is after a given offset of a given time period.
alpha// Makes sure the field under validation is alpha only.
alphaNumeric// Makes sure the field under validation is alpha numeric only.
array// Ensure the value is a valid array. Also this validation will never validate the size of array.
before// Ensures the value of field under validation is before a given date.
beforeOffsetOf// Ensures the date is before a given offset of a given time period.
boolean// Ensures the value of a field is a boolean.
confirmed// Ensures a field value as confirmed using a _confirmation convention. This is mainly used for password confirmation field.
date// Ensures the field under validation is a valid date. The value can be a date object or a valid date string.
dateFormat// Ensures the date or date time is valid as the one of the defined formats.
different// Ensures the value of the field under validation is always different from the targeted field value.
email// Ensures the field under validation is a valid email format.
endsWith// Ensure the value of field under validation ends with a certain substr. This validation will also trim whitespaces before making the check.
equals// Ensures 2 values are lossely same. This validation will not check for the same type, but instead checks for the same value.
in// Ensures the value of a given field matches one of expected values.
includes// Ensures the value of field under validation contains a given substring.
integer// Ensures the value is a valid integer. Also string representation of a number will return true.
ip// Ensures the value is a valid ip address as per ipv4 and ipv6 specs.
ipv4// Ensures the value is a valid ip address as per ipv4 spec only.
ipv6// Ensures the value is a valid ip address as per ipv6 spec only.
json// Ensures the value of field under validation is safe to be parsed using JSON.parse method.
max// Ensures the length of a string or array is not greater than the defined length.
min// Ensures the length of a string or array is not is not less than the expected length
notEquals// Makes sure that the value of field under validation is not same as the defined value.
notIn// Makes sure that the value of field under validation is not from one of the defined values.
number// Makes sure that the value of field under validation is a valid number. The validation will pass for floats too, since it uses typeof internally.
object// Ensures the value of field under validation is a valid Javascript object. The validation will fail for Arrays, though they are objects too in Javascript.
range// Ensures the value of field under validation is under a given range. The values will be cased to Number automatically.
regex// Ensures the value of field under validation, passes the regex test. The regex can be defined as a string or a RegExp object.
required// Ensures the value of field under validation is not empty (i.e. not an empty object, empty array, empty string, null or undefined).
requiredIf// The field is checked for required validation, when expected field exists.
requiredWhen// The field is checked for required validation, when expected field value is same as the expected value.
requiredWithAll// Ensures the field is required when all other fields have non-empty values.
requiredWithAny// Ensures the field is required when any of the other fields have non-empty values.
requiredWithoutAll// Ensures the field is required when all of the other fields has empty values.
requiredWithoutAny// Ensures the field is required when any of the other fields has empty values.
same// Ensures the value of 2 fields are same.
startsWith// Ensure the value of field under validation starts with a certain substr. This validation will also trim whitespaces before making the check.
string// Ensures the value is a string.
under// Ensures the value of a field is under a certain value. All values will be casted to Number.
instance.associate(id)// Exclusive to belongsTo relationship, where it associates two model instances together.
instance.dissociate(id)// The opposite of associate, where you just drop the relationship
instance.attach(arrayOfIds,callback)// Works with the belongsToMany relationship to attach a relationship inside the pivot table. The attach method accepts an optional callback receiving the pivotModel instance, allowing you to set extra properties on a pivot table if required:
instance.detach(arrayOfIds)// The opposite of the attach method, and it removes the relationship from the pivot table only.
Event.on(event,listener)// Bind single or multiple listeners for a given event. The listener can be a closure function or reference to one (or many) IoC container bindings.
Event.when(event,listener)// The when method aliases the on method.
Event.once(event,listener)// Same as on, but only called one time.
Event.onAny(listener)// Bind listener for any event
Event.times(number)// The times method is chained with on or when to limit the number of times the listener should be fired.
Event.emit(event,data)// Emit an event with optional data.
Event.fire(event,data)// The fire method aliases the emit method.
Event.removeListener(event,listener)// Remove listener(s) for a given event.
Event.off(event,listener)// The off method aliases the removeListener method.
Event.removeAllListeners(event)// Remove all listeners for a given event.
Event.listenersCount(event)// Return the number of listeners for a given event.
Event.getListeners(event)// Return an array of listeners for a given event.
Event.hasListeners(event)// Return a boolean indicating whether there are any listeners for a given event.