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.
No description
Get the contents of the view instance.
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 396
mixed
__call(string $method, array $parameters)
Dynamically bind parameters to the view.
at line 39
__construct(Factory $factory, Engine $engine, string $view, string $path, mixed $data = [])
Create a new view instance.
at line 52
HtmlString
fragment(string $fragment)
Get the evaluated contents of a given fragment.
at line 64
string
fragments(array|null $fragments = null)
Get the evaluated contents for a given array of fragments or return all fragments.
at line 74
string|Htmlable
fragmentIf(bool $boolean, string $fragment)
Get the evaluated contents of a given fragment if the given condition is true.
at line 86
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 98
protected string
allFragments()
Get all fragments as a single string.
at line 109
string
render(callable|null $callback = null)
Get the string contents of the view.
at line 122
protected mixed
doRender(callable|null $callback = null)
No description
at line 145
protected string
renderContents()
Get the contents of the view instance.
at line 169
protected string
getContents()
Get the evaluated contents of the view.
at line 177
array
gatherData()
Get the data bound to the view instance.
at line 198
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 221
View
with(string|array $key, mixed $value = null)
Add a piece of data to the view.
at line 235
View
nest(string $key, string $view, array $data = [])
Add a view instance to the view data.
at line 243
View
withErrors(MessageProvider|array|string $provider, string $bag = 'default')
Add validation errors to the view.
at line 254
protected MessageBag
formatErrors(MessageProvider|array|string $provider)
Parse the given errors into an appropriate value.
at line 264
string
name()
Get the name of the view.
at line 272
string
getName()
Get the name of the view.
at line 280
array
getData()
Get the array of view data.
at line 288
string
getPath()
Get the path to the view file.
at line 296
void
setPath(string $path)
Set the path to the view.
at line 304
Factory
getFactory()
Get the view factory instance.
at line 312
Engine
getEngine()
Get the view's rendering engine.
at line 320
bool
offsetExists(mixed $key)
Determine if a piece of data is bound.
at line 328
mixed
offsetGet(mixed $key)
Get a piece of bound data to the view.
at line 336
void
offsetSet(mixed $key, mixed $value)
Set a piece of data on the view.
at line 344
void
offsetUnset(mixed $key)
Unset a piece of data from the view.
at line 352
static void
flushState()
Flush all static state.
at line 360
mixed
__get(string $key)
Get a piece of data from the view.
at line 368
void
__set(string $key, mixed $value)
Set a piece of data on the view.
at line 376
bool
__isset(string $key)
Check if a piece of data is bound to the view.
at line 384
void
__unset(string $key)
Remove a piece of bound data from the view.
at line 418
string
toHtml()
Get content as a string of HTML.
at line 428
string
__toString()
Get the string contents of the view.