1. Go to this page and download the library: Download bkwld/cloner 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/ */
class Article extends Eloquent {
use \Bkwld\Cloner\Cloneable;
protected $cloneable_relations = ['photos', 'authors'];
public function photos() {
return $this->hasMany('Photo');
}
public function authors() {
return $this->belongsToMany('Author');
}
}
class Photo extends Eloquent {
use \Bkwld\Cloner\Cloneable;
protected $clone_exempt_attributes = ['uid', 'source'];
public function article() {
return $this->belongsTo('Article');
}
public function onCloning($src, $child = null) {
$this->uid = str_random();
if($child) echo 'This was cloned as a relation!';
echo 'The original key is: '.$src->getKey();
}
}
class Photo extends Eloquent {
use \Bkwld\Cloner\Cloneable;
protected $cloneable_file_attributes = ['image'];
public function article() {
return $this->belongsTo('Article');
}
}
App::singleton('cloner.attachment-adapter', function($app) {
return new CustomAttachmentAdapter;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.