View

class View implements ArrayAccess, Htmlable, View (View source)

Traits

Macroable

Properties

static protected array $macros The registered string macros. from Macroable
protected Factory $factory The view factory instance.
protected Engine $engine The engine implementation.
protected string $view The name of the view.
protected array $data The array of view data.
protected string $path The path to the view file.

Methods

static void macro(string $name, object|callable $macro)

Register a custom macro.

from Macroable
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

from Macroable
static bool hasMacro(string $name)

Checks if macro is registered.

from Macroable
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
View __call(string $method, array $parameters)

Dynamically bind parameters to the view.

void __construct(Factory $factory, Engine $engine, string $view, string $path, mixed $data = [])

Create a new view instance.

string render(callable $callback = null)

Get the string contents of the view.

string renderContents()

Get the contents of the view instance.

string getContents()

Get the evaluated contents of the view.

array gatherData()

Get the data bound to the view instance.

array renderSections()

Get the sections of the rendered view.

$this with(string|array $key, mixed $value = null)

Add a piece of data to the view.

$this nest(string $key, string $view, array $data = [])

Add a view instance to the view data.

$this withErrors(MessageProvider|array $provider, string $bag = 'default')

Add validation errors to the view.

MessageBag formatErrors(MessageProvider|array|string $provider)

Parse the given errors into an appropriate value.

string name()

Get the name of the view.

string getName()

Get the name of the view.

array getData()

Get the array of view data.

string getPath()

Get the path to the view file.

void setPath(string $path)

Set the path to the view.

Factory getFactory()

Get the view factory instance.

Engine getEngine()

Get the view's rendering engine.

bool offsetExists(string $key)

Determine if a piece of data is bound.

mixed offsetGet(string $key)

Get a piece of bound data to the view.

void offsetSet(string $key, mixed $value)

Set a piece of data on the view.

void offsetUnset(string $key)

Unset a piece of data from the view.

mixed __get(string $key)

Get a piece of data from the view.

void __set(string $key, mixed $value)

Set a piece of data on the view.

bool __isset(string $key)

Check if a piece of data is bound to the view.

void __unset(string $key)

Remove a piece of bound data from the view.

string toHtml()

Get content as a string of HTML.

string __toString()

Get the string contents of the view.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

View __call(string $method, array $parameters)

Dynamically bind parameters to the view.

Parameters

string $method
array $parameters

Return Value

View

Exceptions

BadMethodCallException

void __construct(Factory $factory, Engine $engine, string $view, string $path, mixed $data = [])

Create a new view instance.

Parameters

Factory $factory
Engine $engine
string $view
string $path
mixed $data

Return Value

void

string render(callable $callback = null)

Get the string contents of the view.

Parameters

callable $callback

Return Value

string

Exceptions

Throwable

protected string renderContents()

Get the contents of the view instance.

Return Value

string

protected string getContents()

Get the evaluated contents of the view.

Return Value

string

array gatherData()

Get the data bound to the view instance.

Return Value

array

array renderSections()

Get the sections of the rendered view.

Return Value

array

Exceptions

Throwable

$this with(string|array $key, mixed $value = null)

Add a piece of data to the view.

Parameters

string|array $key
mixed $value

Return Value

$this

$this nest(string $key, string $view, array $data = [])

Add a view instance to the view data.

Parameters

string $key
string $view
array $data

Return Value

$this

$this withErrors(MessageProvider|array $provider, string $bag = 'default')

Add validation errors to the view.

Parameters

MessageProvider|array $provider
string $bag

Return Value

$this

protected MessageBag formatErrors(MessageProvider|array|string $provider)

Parse the given errors into an appropriate value.

Parameters

MessageProvider|array|string $provider

Return Value

MessageBag

string name()

Get the name of the view.

Return Value

string

string getName()

Get the name of the view.

Return Value

string

array getData()

Get the array of view data.

Return Value

array

string getPath()

Get the path to the view file.

Return Value

string

void setPath(string $path)

Set the path to the view.

Parameters

string $path

Return Value

void

Factory getFactory()

Get the view factory instance.

Return Value

Factory

Engine getEngine()

Get the view's rendering engine.

Return Value

Engine

bool offsetExists(string $key)

Determine if a piece of data is bound.

Parameters

string $key

Return Value

bool

mixed offsetGet(string $key)

Get a piece of bound data to the view.

Parameters

string $key

Return Value

mixed

void offsetSet(string $key, mixed $value)

Set a piece of data on the view.

Parameters

string $key
mixed $value

Return Value

void

void offsetUnset(string $key)

Unset a piece of data from the view.

Parameters

string $key

Return Value

void

mixed __get(string $key)

Get a piece of data from the view.

Parameters

string $key

Return Value

mixed

void __set(string $key, mixed $value)

Set a piece of data on the view.

Parameters

string $key
mixed $value

Return Value

void

bool __isset(string $key)

Check if a piece of data is bound to the view.

Parameters

string $key

Return Value

bool

void __unset(string $key)

Remove a piece of bound data from the view.

Parameters

string $key

Return Value

void

string toHtml()

Get content as a string of HTML.

Return Value

string

string __toString()

Get the string contents of the view.

Return Value

string

Exceptions

Throwable

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/View/View.html