Download the PHP package neurony/laravel-duplicate without Composer

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

Package discontinued! Check out VARBOX.IO instead.

Unfortunately this package is now discontinued.
Please check out Varbox (Laravel Admin Panel) for this functionality and much more.

Thank you!


Duplicate any Eloquent model along with its relationships

Build Status StyleCI Scrutinizer Code Quality

Overview

This package allows you to duplicate any Eloquent model record along with its underlying relationships.

Relationship types that can and will make sense to be duplicated: hasOne, morphOne, hasMany, morphMany, belongsToMany, morphToMany

Installation

Install the package via Composer:

Usage

Step 1

Your Eloquent models should use the Neurony\Duplicate\Traits\HasDuplicates trait and the Neurony\Duplicate\Options\DuplicateOptions class.

The trait contains an abstract method getDuplicateOptions() that you must implement yourself.

Here's an example of how to implement the trait:

Step 2

Once you've used the Neurony\Duplicate\Traits\HasDuplicates trait in your Eloquent models, you can duplicate model records by using the saveAsDuplicate() method present on that trait.

Customisations

Exclude certain columns

When duplicating a model, you can exclude certain columns from being duplicated by using the excludeColumns() method in your definition of the getDuplicateOptions() method.

The fields specified in the excludeColumns() method will be saved with their default value (null, false, 0, etc.)

Specify unique columns

When duplicating a model, you can save certain columns in an unique format by using the uniqueColumns() method in your definition of the getDuplicateOptions() method.

The fields specified in the uniqueColumns() method will be saved in a unique format by appending (n) at the end.
Example: original name (1), original name (2)

Exclude entire relations

By default, when duplicating a model, all of its "child" relations (see Overview) are also duplicated along with it.

You can exclude certain relations from being duplicated by using the excludeRelations() method in your definition of the getDuplicateOptions() method.

The relations specified in the excludeRelations() method will not be duplicated along with the targeted model, meaning that the newly duplicated model will not have any records associated to it for the specified relations.

Exclude certain columns from certain relations

When duplicating a model, you can exclude certain columns of its "child" relations from being duplicated by using the excludeRelationColumns() method in your definition of the getDuplicateOptions() method.

This method accepts only one parameter which should be an associative array containing:
key -> the name of a relation
value -> an array containing the columns to exclude for that relation

The fields specified in the excludeRelationColumns() method will be saved with their default value (null, false, 0, etc.)

Specify unique columns for certain relations

When duplicating a model, you can save certain columns of its "child" relations in an unique format by using the uniqueRelationColumns() method in your definition of the getDuplicateOptions() method.

This method accepts only one parameter which should be an associative array containing:
key -> the name of a relation
value -> an array containing the unique columns for that relation

The fields specified in the uniqueRelationColumns() method will be saved in an unique format by appending (n) at the end.
Example: original relation name (1), original relation name (2)

Duplicate only the targeted model

If you only want to duplicate your targeted model without duplicating any relations whatsoever, you can specify this by using the disableDeepDuplication() method in your definition of the getDuplicateOptions() method.

When using this method, all relations of all types will be ignored when duplicating the model.

Events

The duplicate functionality comes packed with two Eloquent events: duplicating and duplicated

You can implement these events in your Eloquent models as you would implement any other Eloquent events that come with the Laravel framework.

Credits

Security

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

License

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

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.


All versions of laravel-duplicate with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.5
illuminate/contracts Version ^7.0
illuminate/support Version ^7.0
illuminate/database Version ^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 neurony/laravel-duplicate contains the following files

Loading the files please wait ....