Generate UUID for a Laravel Eloquent model attribute

Overview

Laravel Eloquent UUID

Latest Version Software License Build Status Total Downloads

Generate UUID for a Laravel Eloquent model attribute.

Installation

composer require stayallive/laravel-eloquent-uuid

Usage

Adding the UsesUUID trait will ensure that the key attribute will be filled with a UUID.



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Stayallive\Laravel\Eloquent\UUID\UsesUUID;

class SomeModel extends Model
{
    use UsesUUID;

    /**
     * This method is not needed but can be used to override which attribute is filled with the UUID.
     */
    public function getUUIDAttributeName(): string
    {
        return $this->getKeyName();
    }
}

Security Vulnerabilities

If you discover a security vulnerability within this package, please send an e-mail to Alex Bouma at [email protected]. All security vulnerabilities will be swiftly addressed.

License

This package is open-sourced software licensed under the MIT license.

You might also like...
The idea of this package is using PHP Attribute in a laravel project

Laravel #[Annotation] Introduction PHP 8.0 release was a revolution for the language. It brings cool features like Named arguments, Attributes, Constr

A laravel package to handle sanitize process of model data to create/update model records.

Laravel Model UUID A simple package to sanitize model data to create/update table records. Installation Require the package using composer: composer r

A package to filter laravel model based on query params or retrieved model collection

Laravel Filterable A package to filter laravel model based on query params or retrived model collection. Installation Require/Install the package usin

Laravel-model-mapper - Map your model attributes to class properties with ease.
Laravel-model-mapper - Map your model attributes to class properties with ease.

Laravel Model-Property Mapper This package provides functionality to map your model attributes to local class properties with the same names. The pack

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

Laravel Quran is static Eloquent model for Quran.

Laravel Quran بِسْمِ ٱللّٰهِ الرَّحْمٰنِ الرَّحِيْمِ Laravel Quran is static Eloquent model for Quran. The Quran has never changed and never will, bec

A package for Laravel One Time Password (OTP) generator and validation without Eloquent Model, since it done by Cache.

Laravel OTP Introduction A package for Laravel One Time Password (OTP) generator and validation without Eloquent Model, since it done by Cache. The ca

Releases(v1.0.1)
Owner
Alex Bouma
PHP artisan, full stack dev and server wrangler | Founder @simulise | Building chief.app @irongate | Laravel / PHP SDK dev @getsentry
Alex Bouma
This package provides a trait that will generate a unique uuid when saving any Eloquent model.

Generate slugs when saving Eloquent models This package provides a trait that will generate a unique uuid when saving any Eloquent model. $model = new

Abdul Kudus 2 Oct 14, 2021
🔥 Fire events on attribute changes of your Eloquent model

class Order extends Model { protected $dispatchesEvents = [ 'status:shipped' => OrderShipped::class, 'note:*' => OrderNoteChanged:

Jan-Paul Kleemans 252 Dec 7, 2022
A laravel package to attach uuid to model classes

Laravel Model UUID A simple package to generate model uuid for laravel models Installation Require the package using composer: composer require touhid

null 10 Jan 20, 2022
Use auto generated UUID slugs to identify and retrieve your Eloquent models.

Laravel Eloquent UUID slug Summary About Features Requirements Installation Examples Compatibility table Alternatives Tests About By default, when get

Khalyomede 25 Dec 14, 2022
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

GoldSpec Digital 501 Jan 4, 2023
PHP 8 attribute to register Laravel model observers.

PHP 8 attribute to register Laravel model observers. Instead of defining observers inside service providers this package offers an alternative way to

gpanos 15 May 30, 2022
Observe (and react to) attribute changes made on Eloquent models.

Laravel Attribute Observer Requirements PHP: 7.4+ Laravel: 7+ Installation You can install the package via composer: composer require alexstewartja/la

Alex Stewart 55 Jan 4, 2023
A laravel package to generate model hashid based on model id column.

Laravel Model Hashid A package to generate model hash id from the model auto increment id for laravel models Installation Require the package using co

Touhidur Rahman 13 Jan 20, 2022
This package lets you add uuid as primary key in your laravel applications

laravel-model-uuid A Laravel package to add uuid to models Table of contents Installation Configuration Model Uuid Publishing files / configurations I

salman zafar 10 May 17, 2022
Use UUID or Ulid as optional or primary key in Laravel.

Laravel OptiKey Use UUID or Ulid as optional or primary key in Laravel. composer require riipandi/laravel-optikey This package adds a very simple trai

Aris Ripandi 33 Nov 4, 2022