PHP code example of firevel / model-random-id

1. Go to this page and download the library: Download firevel/model-random-id 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/ */

    

firevel / model-random-id example snippets


Schema::create('posts', function (Blueprint $table) {
    $table->bigInteger('id')->primary();
    // ... other columns
});

use Firevel\ModelRandomId\HasRandomId;

class Post extends Model
{
    use HasRandomId;
}

$post = Post::create(['title' => 'Hello']);
$post->id; // e.g. 7193428815320495

class Invite extends Model
{
    use HasRandomId;

    public $randomIdKeyName = 'token';
}

class Order extends Model
{
    use HasRandomId;

    public $minimumRandomId = 1000000000;
    public $maximumRandomId = 9999999999;
}