PHP code example of alecgarcia / laravel-uid

1. Go to this page and download the library: Download alecgarcia/laravel-uid 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/ */

    

alecgarcia / laravel-uid example snippets

bash
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('uid', 32)->after('id')->unique();
        });
    }
    
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('uid');
        });
    }
bash
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('uid', 32)->unique();
            $table->timestamps();
        });
    }
bash
$ php artisan vendor:publish --tag laravel-uid.config
bash


return [
    /*
    |--------------------------------------------------------------------------
    | Customize how the uid is created and used
    |--------------------------------------------------------------------------
    */
    'characters' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
    'prefix_separator' => '_',
    'uid_column' => 'uid',
    'length' => 16,
    'check' => true,
];