eloquent-uuid | flexible Laravel package that adds support | Identity Management library

 by   YourAppRocks PHP Version: Current License: MIT

kandi X-RAY | eloquent-uuid Summary

kandi X-RAY | eloquent-uuid Summary

eloquent-uuid is a PHP library typically used in Security, Identity Management applications. 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 universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. is a 36 character long identifier made up of 32 alphanumeric characters with four hyphens in amongst it. For example:123E4567-E89b-12D3-A456-426655440000 containing letters and numbers. that will uniquely identify something. you can read more here.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              eloquent-uuid has a low active ecosystem.
              It has 68 star(s) with 6 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 5 have been closed. On average issues are closed in 3 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of eloquent-uuid is current.

            kandi-Quality Quality

              eloquent-uuid has no bugs reported.

            kandi-Security Security

              eloquent-uuid has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              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

              eloquent-uuid releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed eloquent-uuid and discovered the below as its top functions. This is intended to give you an instant insight into eloquent-uuid implemented functionality, and help decide if they suit your requirements.
            • Boot the has - uuid column .
            • Generate a unique UUID
            • Find by uuid .
            • Validate UUID version
            • Assert that the model has uuid column .
            • Validate a UUID .
            • Get uuid .
            • Set UUID .
            • Get the UUID string .
            • Get the route key .
            Get all kandi verified functions for this library.

            eloquent-uuid Key Features

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

            eloquent-uuid Examples and Code Snippets

            No Code Snippets are available at this moment for 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 eloquent-uuid

            You can install the package via Composer:. or via composer.json file.

            Support

            Please see CONTRIBUTING for details.
            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/YourAppRocks/eloquent-uuid.git

          • CLI

            gh repo clone YourAppRocks/eloquent-uuid

          • sshUrl

            git@github.com:YourAppRocks/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