for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ElfSundae\Laravel\Hashid\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
class AlphabetGenerateCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'hashid:alphabet';
* The console command description.
protected $description = 'Generate a random alphabet for Hashid encoding';
* Execute the console command.
* @return mixed
public function handle()
for ($i = 0; $i < $this->option('times'); $i++) {
$this->comment(
$this->generateRandomAlphabet($this->option('characters'))
);
}
* Generate random alphabet.
* @return string
protected function generateRandomAlphabet($characters)
return str_shuffle(count_chars($characters, 3));
* Get the console command options.
* @return array
protected function getOptions()
return [
['characters', 'c', InputOption::VALUE_OPTIONAL, 'Use custom characters', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'],
['times', 't', InputOption::VALUE_OPTIONAL, 'Times to generate', 1],
];