Pagekit\Widget\Controller\WidgetApiController::copyAction PHP Method

copyAction() public method

public copyAction ( $ids = [] )
    public function copyAction($ids = [])
    {
        foreach ($ids as $id) {
            if ($widget = Widget::find((int) $id)) {
                $copy = clone $widget;
                $copy->id = null;
                $copy->status = 0;
                $copy->title = $widget->title . ' - ' . __('Copy');
                $copy->save();
            }
        }
        return ['message' => 'success'];
    }