laravel-hasuuid maintained by swapneal-dev
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.