Download the PHP package dragosmocrii/model-meta without Composer

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

Laravel Model Meta

Introduction

The Model Meta package for Laravel 5.3 allows you to easily store and retrieve meta data for any models. This package is an implementation of the Property Bag pattern, which is supposed to help you deal with the situations when you need to store various model properties (meta), but adding the properties to the model is not a viable option.

Installation

Composer

Laravel Provider

Next, you need to add the ModelMetaServiceProvider to your providers array in config/app.php :

Migrate & Publish resources

The Model Meta needs to set up its table. To do so, run php artisan migrate.

Next, run php artisan vendor:publish --provider="DragoshMocrii\ModelMeta\ModelMetaServiceProvider" to copy the vendor files to your application.

Configuration

Model Setup

To add the Model Meta functionality, you need to add the MetableFunctionality trait to your model like so:

Usage

Setting meta

bool metaSet(string $key, mixed $value, bool $force = true)

If $force is set to false, the meta will be saved to DB when the parent model is saved. Otherwise, the meta will be saved instantly.

Note: The $key needs to be a string, otherwise an Exception will be thrown.

Setting meta on a new model

Setting meta on an existing model

Setting multiple meta at once

bool metaSetMany(array $values, bool $force = true)

If $force is set to false, the meta will be saved to DB when the parent model is saved. Otherwise, the meta will be saved instantly.

Note: The $values parameter needs to be an associative array, where the key is a string. If these conditions are not met, an Exception will be thrown.

Retrieving meta

mixed metaGet(string|array $keys, null|mixed $default = null)

Note: The $default parameter will have effect when retrieving single meta only.

Getting single meta

Getting multiple meta

Getting all meta

mixed metaAll()

Removing meta

metaRemove(string|array $keys)

Note: Meta will be removed from the DB instantly, unless the model is missing the foreign key.

Removing single meta

Removing multiple meta

Check for meta

bool metaExists(string|array $keys, bool $return_missing = false)

If $return_missing is true, this will return an array containing the keys of missing meta. An empty array will be returned if no meta is missing.

Check for single meta

Check for multiple meta

Morph Map

By default, Laravel will use the fully qualified class name to store the type of the related model. If you would like to decouple the application internal structure from the database, you should define a morph map. Thus, if you change the model's class name, or extend the model and don't want to lose the related meta data, you would simply have to change the morph map.

To change the morph map, you need to edit the model_meta.morph_map configuration setting, for example:

Preload all meta with single meta fetching

Sometimes you may call metaGet multiple times in your code. To avoid executing a DB query every time, you can tell Model Meta to preload all model meta when a single meta is retrieved, so that getting subsequent single metas will use the cache instead.

By default, Model Meta will preload the meta. If you would like to disable this, you can set the configuration model_meta.preload_on_get to false.

Model Meta & Laravel

The model meta uses polymorphic relationships to achieve its functionality. You can keep this in mind if you need to build complex queries.

For example, you can fetch meta for a model, using default Laravel methods:

Known issues


All versions of model-meta with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
laravel/framework Version ~5.3
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 dragosmocrii/model-meta contains the following files

Loading the files please wait ....