<commit_before><?php

namespace Nonoesp\Folio\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

//

class ItemClone extends Command
{
    protected $signature = 'folio:clone {id} {newName?}';

	protected $description = 'Clone an existing item (and, optionally, provide a title for the copy).';
	
    public function __construct()
    {
		parent::__construct();
    }

    public function handle()
    {
        try {
            // Item id
            $id = $this->argument('id');
            // Find item by id
            $item = \Item::find($id);
            // Clone if item exists
            if ($item) {
                $this->info('Cloning Item '.$item->id.' - '.$item->title.'..');
                $item->load('properties');
                $new_item = $item->replicate();
                $new_item->slug = null;
                if ($this->argument('newName')) {
                    $new_item->title = $this->argument('newName');
                } else {
                    $new_item->title = $new_item->title.' (copy)';<commit_msg>Enable cloning of trashed items.<commit_after><?php

namespace Nonoesp\Folio\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

//

class ItemClone extends Command
{
    protected $signature = 'folio:clone {id} {newName?}';

	protected $description = 'Clone an existing item (and, optionally, provide a title for the copy).';
	
    public function __construct()
    {
		parent::__construct();
    }

    public function handle()
    {
        try {
            // Item id
            $id = $this->argument('id');
            // Find item by id
            $item = \Item::withTrashed()->find($id);
            // Clone if item exists
            if ($item) {
                $this->info('Cloning Item '.$item->id.' - '.$item->title.'..');
                $item->load('properties');
                $new_item = $item->replicate();
                $new_item->slug = null;
                if ($this->argument('newName')) {
                    $new_item->title = $this->argument('newName');
                } else {
                    $new_item->title = $new_item->title.' (copy)';
{'fraction_non_alphanumeric': 0.14835640138408304, 'fraction_numerical': 0.0, 'mean_word_length': 1.969191270860077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1520748', 'n_tokens_mistral': 655, 'n_tokens_neox': 639, 'n_words': 149}