master

laravel/framework

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

Ask.php

TLDR

This file contains the implementation of the Ask class, which is a component for rendering a question prompt and returning the user's input.

Classes

Ask

The Ask class extends the Component class and provides a method called render(). This method takes a question and an optional default value as arguments and uses the ask() method from the output property to prompt the user with the question and retrieve their input. The user's input is then returned.

<?php

namespace Illuminate\Console\View\Components;

class Ask extends Component
{
    /**
     * Renders the component using the given arguments.
     *
     * @param  string  $question
     * @param  string  $default
     * @return mixed
     */
    public function render($question, $default = null)
    {
        return $this->usingQuestionHelper(fn () => $this->output->ask($question, $default));
    }
}