PHP code example of centagon / laravel-binary-uuid
1. Go to this page and download the library: Download centagon/laravel-binary-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/ */
centagon / laravel-binary-uuid example snippets
Schema::create('table_name', function (Blueprint $table) {
$table->uuid('uuid');
$table->primary('uuid');
});
use Illuminate\Database\Eloquent\Model;
use Spatie\BinaryUuid\HasBinaryUuid;
class TestModel extends Model
{
use HasBinaryUuid;
}
use Illuminate\Database\Eloquent\Model;
use Spatie\BinaryUuid\HasBinaryUuid;
class TestModel extends Model
{
use HasBinaryUuid;
public $incrementing = false;
public function getKeyName()
{
return 'custom_uuid';
}
}
use Illuminate\Database\Eloquent\Model;
use Spatie\BinaryUuid\HasBinaryUuid;
class TestModel extends Model
{
use HasBinaryUuid;
/**
* The suffix for the uuid text attribute
* by default this is '_text'
*
* @var
*/
protected $uuidSuffix = '_str';
/**
* The binary UUID attributes that should be converted to text.
*
* @var array
*/
protected $uuids = [
'country_uuid' // foreign or related key
];
}