swapneal-dev/laravel-hasuuid

Trait for add uuid in models

Installs: 101

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/swapneal-dev/laravel-hasuuid

dev-main 2022-06-23 10:56 UTC

This package is auto-updated.

Last update: 2025-09-23 17:52:00 UTC


README

Install using composer

composer require swapneal-dev/laravel-hasuuid

This package adds a very simple trait to automatically generate a UUID for your Models.

Simply add the "SwapnealDev\LaravelHasUuid\HasUuid;" trait to your model:

<?php

namespace App;

use SwapnealDev\LaravelHasUuid\HasUuid;
use Illuminate\Database\Eloquent\Model;

class Project extends Model
{

    use HasUuid;

}

It supports any column name for uuid default is uuid.
add below line to your model.

public string $uuidKey = 'uuid_key_name';

You can find by uuid in model;

$project = Project::findByUuid($uuid);

It will return Model object or empty object.