在同一模型中复制字段 - OctoberCMS
Copying fields within the same Model - OctoberCMS
大家早上好,
我正在尝试创建一个按钮来复制组织地址并填充组织帐单地址字段。我不知道从哪里开始。
有问题的字段是:
// I want to copy these values
$organisation->email = Input::get('email');
$organisation->line_1 = Input::get('line_1');
$organisation->line_2 = Input::get('line_2');
$organisation->line_3 = Input::get('line_3');
$organisation->city = Input::get('city');
$organisation->state = Input::get('state');
$organisation->postcode = Input::get('postcode');
$organisation->country = Input::get('country');
// To these fields
$organisation->billing_line_1 = Input::get('billing_line_1');
$organisation->billing_line_2 = Input::get('billing_line_2');
$organisation->billing_line_3 = Input::get('billing_line_3');
$organisation->billing_city = Input::get('billing_city');
$organisation->billing_state = Input::get('billing_state');
$organisation->billing_postcode = Input::get('billing_postcode');
$organisation->billing_country = Input::get('billing_country');
这是我的函数的开始
// Copy Address Button
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
// Copy address logic here
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}
这是我想出的解决方案。
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
$organisation->billing_line_1 = Input::get('line_1');
$organisation->billing_line_2 = Input::get('line_2');
$organisation->billing_line_3 = Input::get('line_3');
$organisation->billing_city = Input::get('city');
$organisation->billing_state = Input::get('state');
$organisation->billing_postcode = Input::get('postcode');
$organisation->billing_country = Input::get('country');
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}
大家早上好,
我正在尝试创建一个按钮来复制组织地址并填充组织帐单地址字段。我不知道从哪里开始。
有问题的字段是:
// I want to copy these values
$organisation->email = Input::get('email');
$organisation->line_1 = Input::get('line_1');
$organisation->line_2 = Input::get('line_2');
$organisation->line_3 = Input::get('line_3');
$organisation->city = Input::get('city');
$organisation->state = Input::get('state');
$organisation->postcode = Input::get('postcode');
$organisation->country = Input::get('country');
// To these fields
$organisation->billing_line_1 = Input::get('billing_line_1');
$organisation->billing_line_2 = Input::get('billing_line_2');
$organisation->billing_line_3 = Input::get('billing_line_3');
$organisation->billing_city = Input::get('billing_city');
$organisation->billing_state = Input::get('billing_state');
$organisation->billing_postcode = Input::get('billing_postcode');
$organisation->billing_country = Input::get('billing_country');
这是我的函数的开始
// Copy Address Button
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
// Copy address logic here
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}
这是我想出的解决方案。
public function onCopyAddress()
{
$organisation = Organisation::find($this->param('id'));
$organisation->billing_line_1 = Input::get('line_1');
$organisation->billing_line_2 = Input::get('line_2');
$organisation->billing_line_3 = Input::get('line_3');
$organisation->billing_city = Input::get('city');
$organisation->billing_state = Input::get('state');
$organisation->billing_postcode = Input::get('postcode');
$organisation->billing_country = Input::get('country');
$organisation->save();
Flash::success($organisation->name." Address has been successfully copied.");
return Redirect::to('/organisations/'.$organisation->id);
}