master

laravel/framework

Last updated at: 29/12/2023 09:21

View.php

TLDR

This file is part of the Illuminate\Contracts\View namespace and it defines the View interface. It extends the Renderable interface and contains three methods: name(), with(), and getData().

Methods

name

This method returns the name of the view as a string.

with

This method allows adding a piece of data to the view. It accepts two parameters: $key, which can be either a string or an array, and $value, which is optional. It returns the instance of the view itself, allowing chaining of method calls.

getData

This method returns an array with the view data.

Note: The file does not contain any classes.

<?php

namespace Illuminate\Contracts\View;

use Illuminate\Contracts\Support\Renderable;

interface View extends Renderable
{
    /**
     * Get the name of the view.
     *
     * @return string
     */
    public function name();

    /**
     * Add a piece of data to the view.
     *
     * @param  string|array  $key
     * @param  mixed  $value
     * @return $this
     */
    public function with($key, $value = null);

    /**
     * Get the array of view data.
     *
     * @return array
     */
    public function getData();
}