laravel-eloquent-uuid | simple drop-in solution for providing UUID support | Identity Management library

 by   goldspecdigital PHP Version: v9.0.0 License: MIT

kandi X-RAY | laravel-eloquent-uuid Summary

kandi X-RAY | laravel-eloquent-uuid Summary

laravel-eloquent-uuid is a PHP library typically used in Security, Identity Management, Laravel applications. laravel-eloquent-uuid has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

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, however should you need v3 or v5 support, you can easily add this in.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              laravel-eloquent-uuid has a low active ecosystem.
              It has 443 star(s) with 32 fork(s). There are 11 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 28 have been closed. On average issues are closed in 26 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of laravel-eloquent-uuid is v9.0.0

            kandi-Quality Quality

              laravel-eloquent-uuid has 0 bugs and 0 code smells.

            kandi-Security Security

              laravel-eloquent-uuid has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              laravel-eloquent-uuid code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              laravel-eloquent-uuid is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              laravel-eloquent-uuid releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed laravel-eloquent-uuid and discovered the below as its top functions. This is intended to give you an instant insight into laravel-eloquent-uuid implemented functionality, and help decide if they suit your requirements.
            • Bootstrap event .
            • Generate UUID .
            • Get options .
            • Bootstrap uuid .
            • Get option .
            • Get model stub .
            • Check if key is uuid
            • Returns uuid version .
            Get all kandi verified functions for this library.

            laravel-eloquent-uuid Key Features

            No Key Features are available at this moment for laravel-eloquent-uuid.

            laravel-eloquent-uuid Examples and Code Snippets

            No Code Snippets are available at this moment for laravel-eloquent-uuid.

            Community Discussions

            QUESTION

            How does one implement primary keys composed of UUIDs, instead of auto-incrementing integers, for Laravel Eloquent models and their relationships?
            Asked 2018-Jun-08 at 18:26

            Auto-incrementing integers cannot be used for primary keys in distributed database topologies in which the potential for conflicts (collisions) exists.

            The extant body of literature regarding the subject of UUIDs vs. auto-incrementing integers is vast, and the fundamental precepts are widely understood. Yet, at the same time, no single, comprehensive explanation of how to achieve this in Laravel, with support for Eloquent Models and relationships, seems to exist.

            The following article is worthwhile and explains the performance overhead incurred for storing primary keys in VARCHAR(36)/CHAR(36) vs the 4/8-byte integer normally used for auto-incrementing keys. We should heed this advice (especially the post-publication corrections that the author notes throughout):

            https://tomharrisonjr.com/uuid-or-guid-as-primary-keys-be-careful-7b2aa3dcb439

            Equally valuable is the commentary that stems from the discussion, which is extensive:

            https://news.ycombinator.com/item?id=14523523

            The following article explains how to implement primary keys using UUIDs in Laravel Eloquent models, but it falls short of explaining how to implement the same for Eloquent relationships, e.g., Many-to-Many with "pivot tables" (per Laravel parlance).

            https://medium.com/@steveazz/setting-up-uuids-in-laravel-5-552412db2088

            Others have asked similar questions, such as Laravel eloquent UUID in a pivot table , but in that instance, the asker is generating the UUID to be inserted in the pivot table using a MySQL trigger, which I would prefer to avoid in favor of a purely-Eloquent approach.

            Another similar question is asked at How To Cast Eloquent Pivot Parameters? , but the crux of the question is how to cast pivot attributes, not how to generate custom values for the ID column upon attaching or synching relationships.

            To be clear, we can achieve this easily by passing the optional array argument to the attach() method:

            ...

            ANSWER

            Answered 2018-Jun-08 at 18:26

            Disclaimer: This is a work-in-progress. As yet, this technique focuses only on Many-to-Many Eloquent relationships, and not the more exotic types, such as Has-Many-Through or Polymorphics.

            Current as of Laravel v5.5.* UUID Generation Packages for Laravel

            Before we get started, we need a mechanism by which to generate UUIDs.

            The most popular package for UUID generation is as follows:

            https://github.com/webpatser/laravel-uuid

            Implemeting UUIDs for Eloquent Models

            The ability for a model to use a UUID as its primary key may be conferred either by extending Laravel's base Model class, or by implementing a trait. Each approach has its strengths and weaknesses, and because Steve Azzopardi's medium.com article (cited above) already explains the trait method (though, it predates Eloquent's $keyType = 'string'; property), I'll demonstrate the Model extension approach, which, of course, may be adapted to a trait with ease.

            Whether we use a model or a trait, the crucial aspects are $incrementing = false; and protected $keyType = 'string';. While extending the base Model class imposes limitations due to PHP's single-inheritance design, it eliminates the need to include these two crucial properties in every model that should utilize a UUID primary key. By contrast, when using a trait, forgetting to include both of these in every model that uses the trait will cause failures.

            The base UUID model class:

            Source https://stackoverflow.com/questions/50766476

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install laravel-eloquent-uuid

            You can download it from GitHub.
            PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.

            Support

            Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/goldspecdigital/laravel-eloquent-uuid.git

          • CLI

            gh repo clone goldspecdigital/laravel-eloquent-uuid

          • sshUrl

            git@github.com:goldspecdigital/laravel-eloquent-uuid.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Identity Management Libraries

            vault

            by hashicorp

            k9s

            by derailed

            keepassxc

            by keepassxreboot

            keycloak

            by keycloak

            uuid

            by uuidjs

            Try Top Libraries by goldspecdigital

            oooas

            by goldspecdigitalPHP

            voodoo-sms-sdk

            by goldspecdigitalPHP

            phpenum

            by goldspecdigitalPHP

            beginners-pipelines

            by goldspecdigitalJavaScript