Download the PHP package touhidurabir/laravel-meta-fields without Composer

On this page you can find all versions of the php package touhidurabir/laravel-meta-fields. 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-meta-fields

Laravel Meta Fields

A php package for laravel framework to handle model meta data in a elegant way.

Installation

Require the package using composer:

To publish the config and migration file:

Configuration

The meta-field config file contains the configuration option of meta table name and meta model. It also provides an cast option that will be applied to meta table's metas column which contains the meta fields as array, object or collection(Laravel Collection) . Read the config file to know more details .

Usage

To use with a model , just use the HasMeta tarit.

And then use it in such way as

As this package use the Illuminate\Database\Eloquent\Relations\MorphMany to maintain a one to many poly morphic relation between the parent model and metas , it is possible to restrict if a model can have multiple metas or not by overriding the HasMeta traits canHaveMultipleMetas method my returning false as :

Also the metas are state aware , that is if the associated parent model got deleted, force deleted or restored , meta recored will follow the same model record state . This is by default enabled . To disable this override syncWithParent directly in the model calss to return false .

As metas are managed as Polymorphic Relations and use laravel's MorphMany relations, all models related functionality are availabel . But this package also provide some additional methods such .

To Update, the updateMeta method such as :

NOTE : if model can have multiple meta records, calling updateMeta will throw exception as not possible to know which one of multiple meta records to update .

To delete, the deleteMeta methods can be used as :

By default metas will be deleted as soft deleted record as this package uses softDelets trait on meta model . to force delete, pass true as the only argument to deleteMeta method .

This package Provide some handly out of box methods to handle metas of a model instance . such as

To Determine if model instance has any meta associated

which will return boolean based on any meta associated with or not.

To Determine if aspecific meta fields associated

To deletermine if a specific metafields associated with model instance, follow as :

By default it will return boolean to indicate if there is any associated meta field associate with this one . But if need those records also , pass true as the second argument which will return collection of matched metas or empty collection if none found.

To get the meta value

To get the meta value of a a given field for a model instance, follow as :

By default, it will only pass one single and first match value even if there is multiple of of meta records that contains the give meta fields . to get all pass true as the second argument which will return an array as list of all values .

Storing Metas and Validation

To make the storing and validattion process of meta easier , this package provide another trait named WithMetaFields whcih can be used with the FormRequest class . This trait has as an abstract method metaRules that must be defined which will contains the validation rules for metas . The package will also use the field name defined in this methods to determine the meta fields .

Use the trait in the FormRequest class as such :

And then from the controller class,

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT


All versions of laravel-meta-fields with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^8.61
illuminate/support Version ^8.61
illuminate/contracts Version ^8.61
illuminate/events Version ^8.61
touhidurabir/laravel-model-uuid Version ^1.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 touhidurabir/laravel-meta-fields contains the following files

Loading the files please wait ....