Skip to content

Commit

Permalink
Improve sqids:alphabet documentation and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbearman committed Feb 15, 2024
1 parent b99faae commit ae0b8ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ Start by publishing the `sqids.php` config file to your `config` directory.
php artisan vendor:publish --provider="RossBearman\Sqids\SqidsServiceProvider"
```

Then generate a new alphabet for your model.
Then generate a new alphabet for your model.

```shell
php artisan sqids:alphabet App\Models\Customer
php artisan sqids:alphabet "App\Models\Customer"
```

You can also generate alphabets for multiple models at once.

```shell
php artisan sqids:alphabet App\Models\Customer App\Models\Order App\Models\Invoice
php artisan sqids:alphabet "App\Models\Customer" "App\Models\Order" "App\Models\Invoice"
```

Follow the instructions provided by the command to add the new keys to your `config/sqids.php` and `.env` files.
Expand Down
13 changes: 10 additions & 3 deletions src/Console/Commands/AlphabetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,22 @@ protected function printPlain(Collection $codecs): void
/** @param Collection<string, SqidCodec> $codecs */
protected function printInstructions(Collection $codecs): void
{
$this->warn('Update your `sqids.php` config file to include the following items:');
if (!file_exists(config_path('sqids.php'))) {
$this->warn('Publish the Eloquent Calamari config file:');
$this->newLine();
$this->info('php artisan vendor:publish --provider="RossBearman\Sqids\SqidsServiceProvider"');
$this->newLine();
}

$this->warn('Update your `config/sqids.php` file to include the following items:');
$this->newLine();
$this->info("'alphabets' => [");

foreach ($codecs as $model => $codec) {
$this->info(" {$model}::class => env('{$this->getEnvKey($model)}')");
$this->info(' ' . $model . "::class => env('{$this->getEnvKey($model)}'),");
}

$this->info("'];");
$this->info('];');
$this->newLine();
$this->warn('And add these keys to your .env:');
$this->newLine();
Expand Down

0 comments on commit ae0b8ae

Please sign in to comment.