# 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.

view('pages.home')

# env

It will read your .env file.

A second parameter can be passed for a default value.

env('DB_CONNECTION')

# pluralize

Pluralize a word.

pluralize('apple')

# singularize

Singularize a word.

singularize('apples')

# request

Return current request.

user()

# user

Return current authenticated user.

user()