Download the PHP package fico7489/laravel-updated-related without Composer

On this page you can find all versions of the php package fico7489/laravel-updated-related. 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-updated-related

Laravel Updated Related

Update Elasticsearch data or clear cache when the model or any related model is updated, created or deleted.

Why to use

In laravel, we have the ability to listen to changes on eloquent models(create, delete, update), and when the model is changed we can do something with model e.g. we can flush cache for this model.

But sometimes we want to do something with the model when this model is changed or related models are changed. For example, you have model Seller with related models Order, ZipCodes, Address and OrderItem. If any change on Seller, Address, Order, ZipCode or OrderItem is performed you want to do something with Seller e.g flush cache for seller because cache include related models data:

In above case when Seller model is changed, we have to flush his cache 'seller'.$id but also when his particular related models are updated we have to flush data. Obviously we need some configuration with related models here and this package will help you with this.

You can add this functionality without the package, but there is another huge problem. You can map related models and parent model to know when to flush cache but if you have batch form, e.g. for update all ZipCodes, and if you have 1000 zip codes and hit save, cache will be flushed 1000 times. This is not a problem for a flushing cache but if you have to update Elasticsearch data or perform some other time-consuming operation then it is.

This package also solves above problem because model changed events are saved to an array and processed after the request when they are filtered to be unique, so if you update 1000 zip codes for the same seller only one event will be dispatched.

Version Compatibility

The package is available for larvel 5.* versions.

Install

1.Install package with composer

2.Add service provider to config/app.php

3.Publish configuration

and after that adjust configuration(map model with related models), see more in below section.

4.Use this trait

in your base model.

and that's it, you are ready to go.

Configuration

Configuration is located at config/laravel-updated-related.php

1.You can create configuration in simple way :

KEYS are base models, VALUES are arrays with related model => relation

2.Or you can create configuration in detailed way if you need more environments for the same base model. :

KEYS are base models, VALUES are arrays with names (environment name) and related configuration (arrays with related model => relation). In "simple way" environment will be 'default'.

After you set a configuration just listened to the ModelChanged event that will be dispatched when any model or its related model (defined in configuration) is changed (updated, deleted, created).

One real example

Configuration :

Models :

Event service provider :

Listener :

With above code you will se this output:

If you create, delete or update User or Address model ModelChanged will be dispatched.

Cover all changes in the database

Do not use code like this one:

Because in that case, laravel does not use a model, it runs query directly without a model. To cover above changes you can change this code to :

Pivot events

If you want to cover pivot events use this package : https://github.com/fico7489/laravel-pivot

When to use this package

License

MIT

Free Software, Hell Yeah!


All versions of laravel-updated-related with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^5.5|^6.0|^7.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 fico7489/laravel-updated-related contains the following files

Loading the files please wait ....