I have a problem with my code. I want to clone a string and into this string, there are three data. Each parameter is a different table of the DB. When I run the code, Yii2 say error:
Call to a member function save() on an array
this is in my controller:
public function actionClone($id)
{
$clone = Helper::get_clone_offer($id);
if ($clone->save()) Helper::add_history(null, null, $id, '',
'Clone', 'Done', 0, 0, 'Offer', 1, 0, '');
return $this->redirect(['index']);
}
this is in my Helper:
public static function get_clone_offer($id)
{
$offer = Offers::findOne($id);
$product = Helper::get_product_name($offer->id);
$accessory = Helper::get_offer_product_accessories($offer->id);
$clone = [$offer,$product,$accessory];
$clone[0]->parent_id = $clone[0]->id;
$clone[0]->id += 1000 ;
return $clone;
}
I'm new in Yii2 and php
.
Thank you for help.