PHPackages                             renoki-co/laravel-useful-casts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. renoki-co/laravel-useful-casts

ActiveLibrary[Database &amp; ORM](/categories/database)

renoki-co/laravel-useful-casts
==============================

Laravel Useful Casts is a simple package for Laravel 7.0+ that comes with already-tested and already-written, useful casts for Eloquent models.

2.2.0(3y ago)103.6k1[1 PRs](https://github.com/renoki-co/laravel-useful-casts/pulls)1Apache-2.0PHPCI passing

Since Oct 21Pushed 3w ago1 watchersCompare

[ Source](https://github.com/renoki-co/laravel-useful-casts)[ Packagist](https://packagist.org/packages/renoki-co/laravel-useful-casts)[ Docs](https://github.com/renoki-co/laravel-useful-casts)[ GitHub Sponsors](https://github.com/rennokki)[ RSS](/packages/renoki-co-laravel-useful-casts/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (7)Versions (11)Used By (1)

Laravel Useful Casts
====================

[](#laravel-useful-casts)

[![CI](https://github.com/renoki-co/laravel-useful-casts/workflows/CI/badge.svg?branch=master)](https://github.com/renoki-co/laravel-useful-casts/workflows/CI/badge.svg?branch=master)[![codecov](https://camo.githubusercontent.com/e759751f51dba21f4cdc7af49b137ab1ab2baae4bef1fee074c36e703c14cda1/68747470733a2f2f636f6465636f762e696f2f67682f72656e6f6b692d636f2f6c61726176656c2d75736566756c2d63617374732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/renoki-co/laravel-useful-casts/branch/master)[![StyleCI](https://camo.githubusercontent.com/482b2095aafa8be15ab8f4cc4f0b0cbaad57c039934a4b80baf64c34049a88ed/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3330323732333931302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/302723910)[![Latest Stable Version](https://camo.githubusercontent.com/27a94495ed9da090eaf050d47aa119796ae6cf97f3a8037879e4c13cd2bb416e/68747470733a2f2f706f7365722e707567782e6f72672f72656e6f6b692d636f2f6c61726176656c2d75736566756c2d63617374732f762f737461626c65)](https://packagist.org/packages/renoki-co/laravel-useful-casts)[![Total Downloads](https://camo.githubusercontent.com/9a1a2c8f961e2090fcce4fe3ee72941336587ddbfb78cc832170f5c4027a6f38/68747470733a2f2f706f7365722e707567782e6f72672f72656e6f6b692d636f2f6c61726176656c2d75736566756c2d63617374732f646f776e6c6f616473)](https://packagist.org/packages/renoki-co/laravel-useful-casts)[![Monthly Downloads](https://camo.githubusercontent.com/0e6da6a51808d703400269efa628b5974cf704f37216030c522e78de1e6ac0ae/68747470733a2f2f706f7365722e707567782e6f72672f72656e6f6b692d636f2f6c61726176656c2d75736566756c2d63617374732f642f6d6f6e74686c79)](https://packagist.org/packages/renoki-co/laravel-useful-casts)[![License](https://camo.githubusercontent.com/bd0891a68d42f5acf08e0bb10ffa993feabff6f3624ca6a331174dbc83fdb499/68747470733a2f2f706f7365722e707567782e6f72672f72656e6f6b692d636f2f6c61726176656c2d75736566756c2d63617374732f6c6963656e7365)](https://packagist.org/packages/renoki-co/laravel-useful-casts)

Laravel Useful Casts is a simple package for Laravel 7.0+ that comes with already-tested and already-written, useful casts for Eloquent models.

🤝 Supporting
------------

[](#-supporting)

**If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with [Github Sponsors](https://github.com/sponsors/rennokki). 📦**

[![](https://camo.githubusercontent.com/4394558e5dd210fe3b08775f3ed97462b849e77804d441c8ed05a9bf75342058/68747470733a2f2f6769746875622d636f6e74656e742e73332e66722d7061722e7363772e636c6f75642f7374617469632f32362e6a7067)](https://github-content.renoki.org/github-repo/26)

🚀 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require renoki-co/laravel-useful-casts
```

🙌 Usage
-------

[](#-usage)

```
use RenokiCo\UsefulCasts\Casts\Encrypted;

class User extends Model
{
    protected $casts = [
        'ssn' => Encrypted::class,
    ];
}

// 'ssn' value gets encrypted in the database.
$user->update(['ssn' => '12345678']);
```

Available Casts
---------------

[](#available-casts)

Cast classPurpose`RenokiCo\UsefulCasts\Casts\Encrypted::class`Encrypts and decrypts a value from the database`RenokiCo\UsefulCasts\Casts\Arrayed::class`Serializes and unserialies an array. If the value is null, returns an empty array.`RenokiCo\UsefulCasts\Casts\EncryptedArray::class`Encrypts and decrypts a value from the database, making sure it's always an array, even if the value is set or get as `null`🐛 Testing
---------

[](#-testing)

```
vendor/bin/phpunit
```

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

🔒 Security
----------

[](#--security)

If you discover any security related issues, please email  instead of using the issue tracker.

🎉 Credits
---------

[](#-credits)

- [Alex Renoki](https://github.com/rennokki)
- [All Contributors](../../contributors)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance62

Regular maintenance activity

Popularity24

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 56.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~218 days

Total

6

Last Release

1125d ago

Major Versions

1.1.1 → 2.0.02021-04-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21983456?v=4)[rennokki](/maintainers/rennokki)[@rennokki](https://github.com/rennokki)

---

Top Contributors

[![rennokki](https://avatars.githubusercontent.com/u/21983456?v=4)](https://github.com/rennokki "rennokki (62 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (42 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

castsdatabaseeloquenteloquent-modelslaravellaravel-packageormphpphplaravelcastcasts

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/renoki-co-laravel-useful-casts/health.svg)

```
[![Health](https://phpackages.com/badges/renoki-co-laravel-useful-casts/health.svg)](https://phpackages.com/packages/renoki-co-laravel-useful-casts)
```

###  Alternatives

[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5462.3k](/packages/io238-laravel-iso-countries)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
