lucasmichot / eloquentcopy
This package is abandoned and no longer maintained.
No replacement package was suggested.
Provides a simple way to duplicate a model instance
0.1
2014-07-08 09:53 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is auto-updated.
Last update: 2024-12-16 21:18:51 UTC
README
Provides a simple way to duplicate a model instance.
Requirements:
- PHP >= 5.4
- Laravel 4.2
Package installation
Begin by installing this package through Composer. Edit your project's composer.json
file to require lucasmichot/eloquentcopy
.
"require": { "lucasmichot/eloquentcopy": "0.*" }
Next, update Composer from the Terminal:
$ composer update
You can achieve these operations with this one-liner command :
$ composer require "lucasmichot/eloquentcopy:0.*"
Usage
use Lucasmichot\Eloquentcopy\CopyTrait; class Post extends Eloquent { use CopyTrait; // the code of your model comes here }
Copying an instance of the model :
$firstPost = Post::create([ 'title' => 'Foo', 'text' => 'Sample text', ]); $secondPost = $firstPost->copy(); // $secondPost has no ID, no created_at and no updated_at attribute $secondPost->save();
TODO
- Finish documentation