Skip to content

Commit 479d5fe

Browse files
[12.x] Improve anticipate method example (#10264)
* Improve anticipate method example * wip * Update artisan.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 9d89b59 commit 479d5fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

artisan.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,13 @@ $name = $this->anticipate('What is your name?', ['Taylor', 'Dayle']);
620620
Alternatively, you may pass a closure as the second argument to the `anticipate` method. The closure will be called each time the user types an input character. The closure should accept a string parameter containing the user's input so far, and return an array of options for auto-completion:
621621

622622
```php
623+
use App\Models\Address;
624+
623625
$name = $this->anticipate('What is your address?', function (string $input) {
624-
// Return auto-completion options...
626+
return Address::whereLike('name', "{$input}%")
627+
->limit(5)
628+
->pluck('name')
629+
->all();
625630
});
626631
```
627632

0 commit comments

Comments
 (0)