lazerg/laravel-choices

There is no license information available for the latest version (v1.0.0) of this package.

v1.0.0 2023-06-06 13:45 UTC

This package is auto-updated.

Last update: 2024-05-06 15:41:26 UTC


README

Version Downloads count Repository count Last commit Stars count

This package allows developers to create command line interfaces for asking questions with a several answers with autocompletion.

Installation

composer require lazerg/laravel-choices

Usage with seeder

use Lazerg\LaravelChoices\ChoicesForSeeders;

class DatabaseSeeder extends Seeder
{
    use ChoicesForSeeders;

    public function run()
    {
      $this
          // Possible answers for this choice is: NO, No, no
          // as second argument does not exist, will skip this step
          // if user select this choice
          ->askWithChoices('No')

          // Possible answers for this choice is: YES, Yes, yes
          // If user select this choice, callback on second argument will be run
          ->addChoice('Yes', fn() => $this->call(FakeDataSeeder::class))

          // Second argument here is default answer,
          // if user press enter without answering
          ->ask('Run FakeDataSeeder?', 'No');
    }
}

Screenshot