PHP code example of rap2hpoutre / has-uuid

1. Go to this page and download the library: Download rap2hpoutre/has-uuid 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/ */

    

rap2hpoutre / has-uuid example snippets



class User {
    
    use \Rap2hpoutre\HasUuid\HasUuid;
    
    // ...
}

$user = User::uuid('e3ae1e6b-fabb-4839-bf65-de9a892c0d56');

$user = new User;
$user->name = 'raph';
$user->save(); // <- Your user has now a UUID (and a ID if you have not removed it)

   
   class CreateSesNotificationsTable extends \Illuminate\Database\Migrations\Migration
   {
       public function up()
       {
           \Schema::create('user', function ($table) {
               $table->increments('id');
               $table->uuid('uuid')->index(); // <- THIS.
               $table->string('email')->index();
               $table->timestamps();
           });
       }
       // ...
   }