ManagementController.php
public function getDuplicate(Request $request)
{
$data = \App\Chalet::find( \Crypt::decrypt($request->input('cid')) );
if ( $data->group_id == Auth::user()->group->group_id ) {
$cid = \Crypt::decrypt($request->input('cid'));
$mid = Extras::getMeta( 'chalet_details', '\App\ChaletMeta', $cid, 'chalet_id', true );
$sid = Extras::getMeta( 'chalet_status', '\App\ChaletMeta', $cid, 'chalet_id', true );
$ciid = Extras::getMeta( 'chalet_images', '\App\ChaletMeta', $cid, 'chalet_id', true );
$arid = Extras::getMeta( 'auto_release_excemption', '\App\ChaletMeta', $cid, 'chalet_id', true );
$rchalet = \App\Chalet::find($cid);
$dup_chalet = $rchalet->replicate();
$dup_chalet->unit_no = '';
$dup_chalet->status = 0;
$dup_chalet->visibility = 1;
$dup_chalet->save();
$nCID = $dup_chalet->chalet_id;
$rmchalet = \App\ChaletMeta::find($mid);
$dupM_chalet = $rmchalet->replicate();
$dupM_chalet->chalet_id = $dup_chalet->chalet_id;
$dupM_chalet->save();
$archalet = \App\ChaletMeta::find($arid);
if ( $archalet ) {
$dupA_chalet = $archalet->replicate();
$dupA_chalet->chalet_id = $dup_chalet->chalet_id;
$dupA_chalet->save();
}
$schalet = \App\ChaletMeta::find($sid);
$dupSChalet = $schalet->replicate();
$dupSChalet->chalet_id = $dup_chalet->chalet_id;
$dupSChalet->save();
$cichalet = \App\ChaletMeta::find($ciid);
$dupCIChalet = $cichalet->replicate();
$dupCIChalet->chalet_id = $dup_chalet->chalet_id;
$dupCIChalet->save();
return Redirect::to(Auth::user()->group->alias.'/app/echalet/view/?cid=' . \Crypt::encrypt($nCID) .'&action=view')->with('message', Extras::alert('success', 'Successful Duplicated Chalet! Please enter Unit #.'))->with('duplicate', true);
} else {
return Redirect::to( Auth::user()->group->alias.'/app/echalet' )->with('message', Extras::alert( 'error', "Something went wrong, Didn't managed to duplicate chalet" ));
}
}
这" get"单击“#34;复制"”按钮后,函数会创建项目的副本。我希望你们可以帮我指出我应该删除哪部分代码,这样我就可以单独发布"帖子"功能
答案 0 :(得分:0)
此代码复制ChatletMeta模型并返回消息。如果要修改方法(GET / POST),可以调用此函数,则需要修改属于此Controller / action的路由。
此外,您可以删除模型复制。