# Global functions

To make development easier, Tea comes with global functions.

# Available functions

dd, json, view, env, pluralize, singularize, request, user

# dd

dd is the equivalent for var_dump($data) die().

dd('Some data')

# json

Return a JSON response.

json(['creator' => 'Devlob'])

A second argument can be passed for the status code, default is 200.

# view

Return a view.

All your views live under /resources/views. Thus /resources/views must be omitted when you link to a view. Instead you can simply pass the directory (if any) and then the name of the view without any extension.

A second parameter can be passed, to pass data to the view.


# env

It will read your .env file.

A second parameter can be passed for a default value.


# pluralize

Pluralize a word.


# singularize

Singularize a word.


# request

Return current request.


# user

Return current authenticated user.