mariusz-buk / files-replicator
OctoberCMS FilesReplicator trait used when replicating any model with files
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:trait
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-09-17 10:11:15 UTC
README
OctoberCMS FilesReplicator trait used when replicating any model with files.
How to use
- Run
composer require "mariusz-buk/files-replicator"
- Define model's properties
$attachOne
and/or$attachMany
. - Add
use FilesReplicator\FilesReplicatorTrait;
to your model class. - For replicating model use
$newModel = $oldModel->replicate()
. That's all. - If you want update existing model with files from other model (of the same class) use
$myModel->replicateFilesFrom($otherModel)
.
About this code
I found it would be useful to replicate files when we replicate model. I saw more coders looked for solution so here it is. I hope you'll find it easy to use.
Any questions/suggestions are welcome.
I provide commercial support for your projects.