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.0.0 2021-04-17 18:35 UTC

This package is auto-updated.

Last update: 2022-01-25 11:59:06 UTC


README

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

68747470733a2f2f6769746875622d636f6e74656e742e73332e66722d7061722e7363772e636c6f75642f7374617469632f32362e6a7067

🚀 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