View
class View implements ArrayAccess, Htmlable, Stringable, View
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $data | The array of view data. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically bind parameters to the view.
Create a new view instance.
Get the evaluated contents of a given fragment.
Get the evaluated contents for a given array of fragments or return all fragments.
Get the evaluated contents of a given fragment if the given condition is true.
Get the evaluated contents for a given array of fragments if the given condition is true.
Get all fragments as a single string.
Get the string contents of the view.
Render the view and return the callback result or the contents.
Get the contents of the view instance.
Get the view contents while notifying completion observers.
Get the evaluated contents of the view.
Get the data bound to the view instance.
Get the sections of the rendered view.
Add validation errors to the view.
Parse the given errors into an appropriate value.
Get the name of the view.
Get the name of the view.
Get the array of view data.
Get the path to the view file.
Set the path to the view.
Get the view factory instance.
Determine if a piece of data is bound.
Get a piece of bound data to the view.
Set a piece of data on the view.
Unset a piece of data from the view.
Flush all static state.
Get a piece of data from the view.
Set a piece of data on the view.
Check if a piece of data is bound to the view.
Remove a piece of bound data from the view.
Get content as a string of HTML.
Get the string contents of the view.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 437
mixed
__call(string $method, array $parameters)
Dynamically bind parameters to the view.
at line 40
__construct(Factory $factory, Engine $engine, string $view, string $path, mixed $data = [])
Create a new view instance.
at line 53
HtmlString
fragment(string $fragment)
Get the evaluated contents of a given fragment.
at line 65
string
fragments(array|null $fragments = null)
Get the evaluated contents for a given array of fragments or return all fragments.
at line 75
string|Htmlable
fragmentIf(bool $boolean, string $fragment)
Get the evaluated contents of a given fragment if the given condition is true.
at line 87
string
fragmentsIf(bool $boolean, array|null $fragments = null)
Get the evaluated contents for a given array of fragments if the given condition is true.
at line 99
protected string
allFragments()
Get all fragments as a single string.
at line 110
string
render(callable|null $callback = null)
Get the string contents of the view.
at line 125
protected mixed
doRender(callable|null $callback = null)
Render the view and return the callback result or the contents.
at line 148
protected string
renderContents()
Get the contents of the view instance.
at line 176
protected string
renderContentsWithObservers()
Get the view contents while notifying completion observers.
at line 210
protected string
getContents()
Get the evaluated contents of the view.
at line 218
array
gatherData()
Get the data bound to the view instance.
at line 239
array
renderSections()
Get the sections of the rendered view.
This function is similar to render. We need to call renderContents function first.
Because sections are only populated during the view rendering process.
at line 262
View
with(string|array $key, mixed $value = null)
Add a piece of data to the view.
at line 276
View
nest(string $key, string $view, array $data = [])
Add a view instance to the view data.
at line 284
View
withErrors(MessageProvider|array|string $provider, string $bag = 'default')
Add validation errors to the view.
at line 295
protected MessageBag
formatErrors(MessageProvider|array|string $provider)
Parse the given errors into an appropriate value.
at line 305
string
name()
Get the name of the view.
at line 313
string
getName()
Get the name of the view.
at line 321
array
getData()
Get the array of view data.
at line 329
string
getPath()
Get the path to the view file.
at line 337
void
setPath(string $path)
Set the path to the view.
at line 345
Factory
getFactory()
Get the view factory instance.
at line 353
Engine
getEngine()
Get the view's rendering engine.
at line 361
bool
offsetExists(mixed $offset)
Determine if a piece of data is bound.
at line 369
mixed
offsetGet(mixed $offset)
Get a piece of bound data to the view.
at line 377
void
offsetSet(mixed $offset, mixed $value)
Set a piece of data on the view.
at line 385
void
offsetUnset(mixed $offset)
Unset a piece of data from the view.
at line 393
static void
flushState()
Flush all static state.
at line 401
mixed
__get(string $key)
Get a piece of data from the view.
at line 409
void
__set(string $key, mixed $value)
Set a piece of data on the view.
at line 417
bool
__isset(string $key)
Check if a piece of data is bound to the view.
at line 425
void
__unset(string $key)
Remove a piece of bound data from the view.
at line 459
string
toHtml()
Get content as a string of HTML.
at line 469
string
__toString()
Get the string contents of the view.