New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

floor9design/laravel-casts-uuid

A class for casting ramsey/uuid into laravel models
5,057
Install
composer require floor9design/laravel-casts-uuid
Latest Version:1.1.1
PHP:>=8.0
Laravel:9 · 10
License:MIT
Last Updated:Feb 16, 2023
Links: GitHub  ·  Packagist
Maintainer: elb98rm

laravel-casts-uuid

Latest Version Software License

Build Status Build Status

Github Downloads Packagist Downloads

Introduction

The Laravel Framework supports casting of types within models. This class adds the ramsey/uuid UUID class support for laravel models.

Install

Add the following to the composer.json:

    "require": {
        "floor9design/laravel-casts-uuid": "^1.0",
    }

Setup

There are no specific config setup steps required. The class should autoload in PSR-4 compliant systems. If you are using the class on its own, simply include it when using a model:

use Floor9design\LaravelCasts\Uuid as UuidCasts;

protected $casts = [
    'uuid' => UuidCasts::class
];

Note the alias - often it is useful to alias the casting class as it can clash with other Uuid classes, such as the base Uuid class:

use Ramsey\Uuid\Uuid;

// somewhere in the code:
$uuid = Uuid::uuid4();

Testing

Build Status Build Status

Tests can be run as follows:

  • ./vendor/phpunit/phpunit/phpunit

Static analysis/code review can be performed by using phpstan:

  • ./vendor/bin/phpstan

The following tests and also creates code coverage (usually maintained at 100%)

  • ./vendor/phpunit/phpunit/phpunit --coverage-html docs/tests/

Credits

Changelog

A changelog is generated here:

License

This software is proprietary.

Related Packages

alhaji-aki/laravel-uuid

Trait to generate uuid when creating models

3,962 2
stayallive/laravel-eloquent-uuid

Generate UUID for a Laravel Eloquent model attribute.

71,246 4
aryehraber/statamic-uuid

One of its kind; unlike anything else

33,172 3
marquine/eloquent-uuid

Uuid primary key for Laravel Eloquent Models

11,534 7
cleaniquecoders/laravel-uuid

Use UUID for your Laravel application.

9,767 3

Version History

Version Released PHP Laravel License
1.1.1 >=8.0 ^10.0|^9.0 MIT
1.1.0 >=8.0 ^10.0|^9.0 MIT
1.0.0 >=8.1 ^9.0 MIT