classes/Controllers/Base.php
public function duplicate($id)
    {
        // Find the source item
        $src = $this->findOrFail($id);
        if (empty($src->cloneable)) {
            return App::abort(404);
        }

        // Duplicate using Bkwld\Cloner
        $new = $src->duplicate();

        // Don't make duplicates public
        if (array_key_exists('public', $new->getAttributes())) {
            $this->public = 0;
        }

        // If there is a name or title field, append " copy" to it.  Use "original"
        // to avoid mutators.
        if ($name = $new->getOriginal('name')) {
            $new->setAttribute('name', $name.' copy');
        } elseif ($title = $new->getOriginal('title')) {
            $new->setAttribute('title', $title.' copy');
        }

        // Set localization options on new instance
        if ($locale = request('locale')) {
            $new->locale = $locale;
            if (isset($src->locale_group)) {
                $new->locale_group = $src->locale_group;
            }
        }

        // Save any changes that were made
        $new->save();

        // Save the new record and redirect to its edit view
        return Redirect::to(DecoyURL::relative('edit', $new->getKey()))
            ->with('success', $this->successMessage($src, 'duplicated'));
    }
public function duplicate($id)
    {
        // Find the source item
        $src = $this->findOrFail($id);
        if (empty($src->cloneable)) {
            return App::abort(404);
        }

        // Duplicate using Bkwld\Cloner
        $new = $src->duplicate();

        // Don't make duplicates public
        if (array_key_exists('public', $new->getAttributes())) {
            $this->public = 0;
        }

        // If there is a name or title field, append " copy" to it.  Use "original"
        // to avoid mutators.
        if ($name = $new->getOriginal('name')) {
            $new->setAttribute('name', $name.' copy');
        } elseif ($title = $new->getOriginal('title')) {
            $new->setAttribute('title', $title.' copy');
        }

        // Set localization options on new instance
        if ($locale = request('locale')) {
            $new->locale = $locale;
            if (isset($src->locale_group)) {
                $new->locale_group = $src->locale_group;
            }
        }

        // Save any changes that were made
        $new->save();

        // Save the new record and redirect to its edit view
        return Redirect::to(DecoyURL::relative('edit', $new->getKey()))
            ->with('success', $this->successMessage($src, 'duplicated'));
    }
public function duplicate ( $ id ) { // Find the source item $ src = $ this -> findOrFail ( $ id ) ; if ( empty ( $ src -> cloneable ) ) { return App :: abort ( 404 ) ; } // Duplicate using Bkwld\Cloner $ new = $ src -> duplicate ( ) ; // Don't make duplicates public if ( array_key_exists ( 'public' , $ new -> getAttributes ( ) ) ) { $ this -> public = 0 ; } // If there is a name or title field, append " copy" to it.  Use "original" // to avoid mutators. if ( $ name = $ new -> getOriginal ( 'name' ) ) { $ new -> setAttribute ( 'name' , $ name . ' copy' ) ; } elseif ( $ title = $ new -> getOriginal ( 'title' ) ) { $ new -> setAttribute ( 'title' , $ title . ' copy' ) ; } // Set localization options on new instance if ( $ locale = request ( 'locale' ) ) { $ new -> locale = $ locale ; if ( isset ( $ src -> locale_group ) ) { $ new -> locale_group = $ src -> locale_group ; } } // Save any changes that were made $ new -> save ( ) ; // Save the new record and redirect to its edit view return Redirect :: to ( DecoyURL :: relative ( 'edit' , $ new -> getKey ( ) ) ) -> with ( 'success' , $ this -> successMessage ( $ src , 'duplicated' ) ) ; }
Duplicate a record

@param  int                                       $id Model key
@return Symfony\Component\HttpFoundation\Response Redirect to new record
Duplicate a record