0
我正在复制旅行桌。在旅行形式上,有一个下拉选择物种。用户可以选择多种物种。我很难复制这个物种表,因为它在它自己的表中,它的一个集合。所以使用“复制”不会工作。复制Laravel系列 - Laravel 5.3
这是林如何复制的车次表现在:
public function replicateTrip (Request $request, $slug, $id) {
$listing = $request->user()->listings()->where('slug', $slug)->first();
$trip = $listing->trips()->where('id', $id)->first();
$replicateTrip = Trip::find($trip->id);
// This is how im getting the species from the species table
$replicateSpecies = DB::table('species_trip')->where('trip_id', $id)->get();
$newTask = $replicateTrip->replicate();
$newTask->save();
return redirect()->back();
}
如果我克隆我的电流跳闸时,DD表示$ replicateSpecies变量,我得到:
我需要从我的原始旅程中复制物种数组到物种表中,并且我不能使用“复制”,因为它是一个集合。
所以我的问题是我将如何复制这个集合?或者如果有另一种方法做到这一点?