在我的控制器中,我有用於存儲和更新的方法。正如你看到的,我在$tour
複製$request
屬性的屬性逐一:複製類屬性中的所有請求屬性
class TourController extends Controller
{
public function store(Request $request, Tour $tour)
{
$tour->name = $request->name;
$tour->flight = $request->flight;
$tour->price = $request->price;
$tour->description = $request->description;
$tour->save();
return redirect('home/tour/see');
}
public function update(Request $request)
{
$tour = Tour::find($request->id);
$tour->name = $request->name;
$tour->flight = $request->flight;
$tour->price = $request->price;
$tour->description = $request->description;
$tour->save();
return redirect('home/tour/see');
}
}
看來,我重複我的代碼,我的問題是,有沒有辦法一次複製所有的人?如何複製遊覽屬性中的所有請求屬性?
@AliSeyfi檢查我的編輯答案 –
這使得$遊覽一個數組,那麼你就不能調用$ tour->保存()上它 –
@AliSeyfi checagain –