PHPackages                             weebly/laravel-mutate - 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. weebly/laravel-mutate

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

weebly/laravel-mutate
=====================

Mutate Laravel attributes

v2.0.0(5mo ago)1356.1k↑51.8%9BSD-2-ClausePHPPHP &gt;=8.1CI failing

Since Sep 7Pushed 5mo ago7 watchersCompare

[ Source](https://github.com/Weebly/laravel-mutate)[ Packagist](https://packagist.org/packages/weebly/laravel-mutate)[ RSS](/packages/weebly-laravel-mutate/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (35)Used By (0)

Eloquent Mutators
=================

[](#eloquent-mutators)

[![License](https://camo.githubusercontent.com/b67e3e8ed40e3c323ce7e3757c944aeaaed3c2f5fddb9f71cc73c5cb720639f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f576565626c792f6c61726176656c2d6d75746174652e737667)](https://packagist.org/packages/weebly/laravel-mutate)[![Latest Stable Version](https://camo.githubusercontent.com/3ea309d0845143412c7ba6b700aa16fa3dbfece45648e30b0072dceb3f886a5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f576565626c792f6c61726176656c2d6d75746174652e737667)](https://packagist.org/packages/weebly/laravel-mutate)[![StyleCI](https://camo.githubusercontent.com/3e9edae83c0ceb058546ac690d204fef210e4ec4458ca3b92dd5a7dd2f10530c/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130323635393334312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/102659341)[![Tests](https://github.com/Weebly/laravel-mutate/actions/workflows/test.yaml/badge.svg)](https://github.com/Weebly/laravel-mutate/actions/workflows/test.yaml/badge.svg)

This package allows you to map your model attributes to database columns when the type in the PHP model does not match the type in the database column.

This could be using `$model->ip_address` as a `string` in your eloquent model but storing it as a `BINARY(16)` in the database for efficiency. Or having a string always encrypted in the DB but readable in clear form within your models.

Installing
----------

[](#installing)

```
$ composer require weebly/laravel-mutate
```

To use this package, you'll need to add the `ServiceProvider` to the providers array in `config/app.php` if you are not using automatic package discovery:

```
Weebly\Mutate\LaravelMutatorServiceProvider::class
```

You'll also need to publish the config to `config/mutators.php` with:

```
$ php artisan vendor:publish --provider='Weebly\Mutate\LaravelMutatorServiceProvider'
```

Usage
-----

[](#usage)

When creating an Eloquent model, you'll need to extend `Weebly\Mutate\Database\Model`and add `$mutate` property it:

```
