lucasmichot / eloquentcopy
此包已被 弃用 且不再维护。未建议替代包。
提供了一种简单的方法来复制模型实例
0.1
2014-07-08 09:53 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2022-02-01 12:36:52 UTC
README
提供了一种简单的方法来复制模型实例。
要求
- PHP >= 5.4
- Laravel 4.2
包安装
首先,通过 Composer 安装此包。编辑你的项目 composer.json
文件,以需要 lucasmichot/eloquentcopy
。
"require": { "lucasmichot/eloquentcopy": "0.*" }
然后,在终端更新 Composer
$ composer update
你可以使用以下单行命令完成这些操作
$ composer require "lucasmichot/eloquentcopy:0.*"
使用方法
use Lucasmichot\Eloquentcopy\CopyTrait; class Post extends Eloquent { use CopyTrait; // the code of your model comes here }
复制模型实例
$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();
待办事项
- 完成文档