Looking to hire Laravel developers? Try LaraJobs

laravel-hasuuid maintained by swapneal-dev

Description
Trait for add uuid in models
Last update
2022/06/23 12:56 (dev-main)
License
Links
Downloads
113
Tags

Comments
comments powered by Disqus

Laravel HasUuid

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.