datakrama/eloquid

Eloquid - Auto UUID for Eloquent Model

v2.0.0 2020-11-04 09:05 UTC

This package is auto-updated.

Last update: 2024-12-14 23:02:13 UTC


README

GitHub Workflow Status Packagist Version Packagist Downloads Packagist License

This package is created to insert UUID into Eloquent Model Primary Key (id) automatically.

Requirement

Laravel Compatibility

Installation

$ composer require datakrama/eloquid:"^2.0"

Usages

Reguler model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Datakrama\Eloquid\Traits\Uuids;

class Role extends Model
{
    use Uuids;
    
    /**
     * The users that belong to the role.
     */
    public function users()
    {
        return $this->belongsToMany('App\User')->using('App\RoleUser');
    }
}

Custom intermediate table model (Pivot)

<?php

namespace App;

use Illuminate\Database\Eloquent\Relations\Pivot;
use Datakrama\Eloquid\Traits\Uuids;

class RoleUser extends Pivot
{
    use Uuids;
    
    //
}

Licence

The MIT License (MIT). Please see License File for more information.