第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

方法 Illuminate\Database\Eloquent\Collection::create

方法 Illuminate\Database\Eloquent\Collection::create

PHP
手掌心 2023-09-08 16:58:09
我想使用視圖中的按鈕將一個表(形式)中的行的值復制到另一個表(發(fā)票)中的行。但出現(xiàn)錯誤:方法 Illuminate\Database\Eloquent\Collection::create 不存在。在線的:'grosstotal' => $proform->grosstotal,這是我的控制器方法:public function duplicate(Request $request){ $proform = $this->proform->findOrFail($request->duplicate);$invoice = Invoice::all();//something like this$duplicated = $invoice->create(['invoicenumber' => $proform->proformnumber,'invoicedate' => $proform->proformdate,'selldate' => $proform->selldate,'user_id' => $proform->user_id,'form_id' => $proform->form_id,'currency_id' => $proform->currency_id,'paymentmethod' => $proform->paymentmethod,'paymentdate' => $proform->paymentdate,'status' => $proform->status,'comments' => $proform->comments,'city' => $proform->city,'autonumber' => $proform->autonumber,'automonth' => $proform->automonth,'autoyear' => $proform->autoyear,'name' => $proform->name,'PKWIU' => $proform->PKWIU,'quantity' => $proform->quantity,'unit' => $proform->unit,'netunit' => $proform->netunit,'nettotal' => $proform->nettotal,'VATrate' => $proform->VATrate,'grossunit' => $proform->grossunit,'grosstotal' => $proform->grosstotal,]);return redirect()->route('invoices.show', ['invoice' => $duplicated]);}
查看完整描述

1 回答

?
當年話下

TA貢獻1890條經(jīng)驗 獲得超9個贊

在你的代碼中你有


// all() gets you the collection of the Invoice Model instances of all the entries of invoice in the database.


$invoice = Invoice::all();


$duplicated = $invoice->create([..

其中 $invoice 是發(fā)票模型實例的集合。您不能create對集合應用方法。


您需要使用您擁有的模型進行創(chuàng)建Invoice。


所以將上面的創(chuàng)建代碼修改為


$duplicated = Invoice::create([..


查看完整回答
反對 回復 2023-09-08
  • 1 回答
  • 0 關注
  • 124 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號