New

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

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.
3,584 11
Install
composer require renoki-co/laravel-useful-casts
Latest Version:2.2.0
Laravel:9 · 10
Older releases:7 · 8
License:Apache-2.0
Last Updated:Sep 21, 2026
Links: GitHub  ·  Packagist
Maintainer: rennokki

Laravel Useful Casts

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

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

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. 📦

🚀 Installation

You can install the package via composer:

composer require renoki-co/laravel-useful-casts

🙌 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

Cast class Purpose
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

vendor/bin/phpunit

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

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

🎉 Credits

Related Packages

vkovic/laravel-custom-casts

Make your own custom cast type for Laravel model attributes

381,460 217
valorin/random

Random is a simple helper package designed to make it easy to generate a range o...

413,065 233
php
lionix/castable-request

Apply Eloquent attribute casts to Laravel form request input.

94,608 23
cline/variable-keys

Laravel Blueprint macros for variable primary key and morph types

22,912 0
php
neuecommerce/model-casts

Some handy Laravel Eloquent model casts.

21,938 0

Version History

Version Released PHP Laravel License
2.2.0 ^9.35|^10.5 Apache-2.0
2.1.0 ^8.83|^9.0.1 Apache-2.0
2.0.0 ^7.30|^8.24 Apache-2.0
1.1.1 ^7.30|^8.23 Apache-2.0
1.1.0 ^7.0|^8.0 Apache-2.0