PHP code example of antcool / laravel-optimus-factory

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

    

antcool / laravel-optimus-factory example snippets


OptimusFactory::encode(1) // 1985404696
OptimusFactory::decode(1985404696) // 1

OptimusFactory::make('scene')->encode(1) // 1059890159
OptimusFactory::make('scene')->decode(1059890159) // 1

use AntCool\OptimusFactory\Traits\UseOptimusId;
class User extends Model
{
    use UseOptimusId;
    
    // encoded field
    protected string $encodeKey = 'user_id';
    
    // scene key in config
    protected string $encodeScene = 'user';
}


bash
php artisan vendor:publish --tag=optimus-factory-config
bash
php artisan optimus:generate scene 31