Download the PHP package mindtwo/laravel-dynamic-model-mutators without Composer

On this page you can find all versions of the php package mindtwo/laravel-dynamic-model-mutators. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-dynamic-model-mutators

Laravel Dynamic Model Mutators

Build Status StyleCI Quality Score Latest Stable Version Total Downloads

Important Notice:

The following documentation refers to packacke version 1.x
We will add documentation for version 2.x as soon as possible. Sorry.

Introduction

This package is an extension for Laravel's eloquent model. It allows you to define multiple get and set mutators by registering your own callback functions. This is a simple way to inject Laravel's getAttribute() and setAttribute() methods, especially within different traits on a single model.

Installation

You can install the package via composer:

How to use?

Use the "DynamicModelMutator" trait in your eloquent models:

In the boot method of the model you can now register the dynamic getter and setter functions e.g.:

registerSetMutator and registerGetMutator expecting two parameters. First is name of mutator, which is the name of the property which configures your attributes for the registered mutator, too. The second is the name of the callback function which will be called on the same object.

Defining attributes for mutators

To define attributes for your mutators you have to set up a class property with the mutator key as its name. For example we use 'translations' as mutator key, so we can setup our attributes by defining an $translations property on our model.

Optionally you can set up a attribute based configuration which will be passed to you mutator methods. So you can add additional configuration to your attributes.

Set mutator callback function

The callback function for a set mutators must accept three arguments. First is the attribute name, second is the attribute value, third is the attribute specific configuration. Because they will be called automatically within the trait, there is no need to return any value.

Get mutator callback function

The callback function for a get mutators must accept two arguments. First is the attribute name, second is the attribute specific configuration. It should return the attribute value for a given attribute name. Note, that you can not use Laravel's attribute casting feature for a dynamic mutated attribute, but it's quite easy to implement our own castings.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-dynamic-model-mutators with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
illuminate/database Version ^7.4|^8.0|^9.0|^10.0
illuminate/support Version ^7.4|^8.0|^9.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mindtwo/laravel-dynamic-model-mutators contains the following files

Loading the files please wait ....