simlux/laravel-model-uuid

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Make usage of UUID in laravel models easy.

Installs: 130

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Type:laravel-package

dev-master 2017-08-26 08:41 UTC

This package is auto-updated.

Last update: 2021-09-07 15:25:26 UTC


README

Installation

composer require simlux/laravel-model-uuid:dev-master

Usage

Creates column uuid and unique index with the migration helper.

<?php

use Illuminate\Database\Eloquent\Model;
use Simlux\LaravelModelUuid\Uuid\UuidModelTrait;

/**
 * Class MyModel
 *
 * @property int    $id
 * @property string $uuid
 *
 * @method static MyModel uuid(string $uuid)
 */
class MyModel extends Model
{
    use UuidModelTrait;
}

Migration

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Simlux\LaravelModelUuid\Migration\UuidMigrationHelper;

class CreateTableRevisions extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('my_models', function (Blueprint $table) {
            $table->unsignedBigInteger('id', true);
            UuidMigrationHelper::uuid($table);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('my_models');
    }
}