PHP code example of laith-zraikat / yii2-uuid-behavior

1. Go to this page and download the library: Download laith-zraikat/yii2-uuid-behavior 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/ */

    

laith-zraikat / yii2-uuid-behavior example snippets


use LaithZraikat\UUID\UUIDBehavior;

class MyModel extends \yii\db\ActiveRecord
{
    public function behaviors()
    {
        return [
            [
                'class' => UUIDBehavior::class,
                'attribute' => 'uuid', // the attribute that will store the UUID
                'method' => UUIDBehavior::METHOD_MYSQL, // or UUIDBehavior::METHOD_PHP
                'keepDashes' => true, // whether to keep dashes in the UUID
                'enableOnUpdate' => false, // whether to generate UUID on update
            ],
        ];
    }
}