Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

lazerg/laravel-choices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Line choices

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages