无法使用laravel eloquent将所有数据从一个表发送到另一个表

gudnpqoy  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(166)

issue an invoice按钮用于将porform表中的一行发送到invoices。大多数列都有相同的名称。有一个问题,因为一半的价值没有转移。我把$proform打给dd($proform),就在那里了。我做错什么了?在这里你可以看到我如何检查grossunit和值​​显示得很好,但不会发送到第二个表。这是我控制器的一部分。

public function duplicate(Request $request)

{

$proform = $this->proform->findOrFail($request->duplicate);

$invoice = Invoice::all();

dd($proform->grossunit);

//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]);

}

这是发票型号:

<?php

namespace App;

use Kyslik\ColumnSortable\Sortable;
use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    /**
     * The attributes that are mass assignable.
     *  
     * @var array
     */
    use Sortable;

    protected $fillable = [
        'invoicenumber', 'invoicedate', 'id', 'selldate', 'user_id', 'paymentmethod', 
        'paymentdate', 'status', 'comments', 'city', 'paid',  'autonumber', 'automonth', 'autoyear', 'name',
         'PKWIU', 'quantity', 'unit', 'netunit', 'nettotal',
         'VATrate', 'grossunit', 'grosstotal', 'form_id', 'currency_id',
    ];

    public $sortable = [     'invoicenumber', 'invoicedate', 'id', 'selldate', 
    'user_id', 'paymentmethod', 'paymentdate', 'status', 'comments', 'grosstotal', 'nettotal', 'form_id', 'currency_id',];

        public function user()
    {
        return $this->belongsTo('App\User');
    }

        public function form()
    {
        return $this->hasOne('App\Form');
    }

         public function currency()
    {
        return $this->hasOne('App\Currency');
    }

        public function proform()
    {
        return $this->belongsTo('App\Proform');
    } 

}

这些字段不适用:名称、pkwiu、数量、单位、净单位、净总额、增值税、总收入、总收入

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题