PHP code example of lucasmichot / eloquentcopy
1. Go to this page and download the library: Download lucasmichot/eloquentcopy library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lucasmichot / eloquentcopy example snippets
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();