PHP code example of finagin / laravel-extra-support

1. Go to this page and download the library: Download finagin/laravel-extra-support library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

finagin / laravel-extra-support example snippets


use Illuminate\Support\Str;

Str::randomWithExclude();
Str::randomWithExclude(15);
Str::randomWithExclude(16, ['a', 'b', 'c']);
Str::randomWithExclude(16, 'abc');

use Illuminate\Support\Str;

Str::randomAlpha();
Str::randomAlpha(15);



namespace App\Services;

use Finagin\ExtraSupport\Services\MacrosRegistrar;
use Illuminate\Support\Str;

class CustomMacrosRegistrar extends MacrosRegistrar
{
    /**
     * @return \Illuminate\Support\Collection|array
     */
    public function additionalRegisters()
    {
        return [
            '\\Illuminate\\Support\\Str@randomExcludeSimilar' => 'registerMacroRandomExcludeSimilar',
        ];
    }

    protected function registerMacroRandomExcludeSimilar()
    {
        Str::macro('randomExcludeSimilar', static function ($length = 16) {
            return Str::randomWithExclude($length, ['1', 'l', '0', 'O']);
        });
    }
}



return [

    'registrar' => \App\Services\CustomMacrosRegistrar::class,
    
    // ...
];



return [
    // ...
    'dependencies' => [
        // ...
        '\\Illuminate\\Support\\Str@randomExcludeSimilar' => [
            '\\Illuminate\\Support\\Str@randomWithExclude',
        ],
        // ...
    ],
    // ...
];