Laravel ["message": "Too few arguments to function App\\Http\\Controllers\\BursaPembelianController::edit_bursa_pembelian(), 1 passed in

huangapple go评论183阅读模式
英文:

Laravel ["message": "Too few arguments to function App\\Http\\Controllers\\BursaPembelianController::edit_bursa_pembelian(), 1 passed in

问题

抱歉,以下是您要求的翻译:

您好,我想问你一些问题,我在我的Laravel项目中遇到了问题,我总是看到错误消息:"message": "App\\\\Http\\\\Controllers\\\\BursaPembelianController::edit_bursa_pembelian()的参数太少..."

请给我提供解决错误消息的解决方案,下面我提供了我创建的源代码视图。

视图:

@extends('layouts.main')
@section('container')

    <body class="InvPinjam()">
        <div class="page-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                            <h4 class="mb-sm-0 font-size-18">{{ $label }}</h4>
                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item">{{ ucwords($menu) }}</li>
                                    <li class="breadcrumb-item">{{ ucwords($submenu) }}</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xl-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-2 peminjam">
                                        <div class="mb-2">
                                            <label>Kode Pembelian <code>*</code></label>
                                            <input type="disable" class="form-control" id="kode_transaksi"
                                                name="kode_transaksi" value="{{ $pembelian->kode_transaksi }}" disabled>
                                            <input type="hidden" name="purchase_id" id="purchase_id"
                                                value="{{ $pembelian->id }}">
                                            <input type="hidden" name="url" id="url"
                                                value="{{ Crypt::encryptString($pembelian->kode_transaksi) }}">
                                        </div>
                                    </div>
                                    <div class="col-md-2 peminjam">
                                        <div class="mb-2">
                                            <label>Tanggal <code>*</code></label>
                                            <input type="disable" class="form-control" name="tgl_kedatangan"
                                                id="tgl_kedatangan" value="{{ $pembelian->tgl_kedatangan }}" readonly>
                                            <input type="disable" class="form-control" name="id_peminjam" id="id_peminjam"
                                                value="" hidden>
                                            {!! $errors->first('nama_peminjam', '<div class="invalid-validasi">:message</div>') !!}
                                        </div>
                                    </div>
                                    <div class="col-md-2 wajib">
                                        <div class="mb-2">
                                            <label>Supplier </label>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="supplier" id="supplier"
                                                    value="{{ $pembelian->id_supplier }}">
                                                <span class="input-group-text"><i class="mdi mdi-calendar"></i></span>

                                            </div>
                                            {!! $errors->first('tgl_permintaan', '<div class="invalid-validasi">:message</div>') !!}
                                        </div>
                                    </div>
                                    <div class="col-md-2 wajib">
                                        <div class="mb-2">
                                            <label>Surat Jalan </label>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="suratjalan" id="suratjalan"
                                                    value="{{ $pembelian->nomor_do }}">
                                                <span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2 wajib">
                                        <div class="mb-2">
                                            <label>Status Pembayaran </label>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="pembayaran" id="pembayaran"
                                                    value="{{ $pembelian->status_pembayaran }}">
                                                <span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2 wajib">
                                        <div class="mb-2">
                                            <label>Potongan </label>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="potongan" id="potongan"
                                                    value="{{ $pembelian->potongan }}">
                                                <span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                {{-- keterengan --}}
                                <div class="row">
                                    <div class="col-md-2 peminjam">
                                        <div class="mb-2">
                                            <label>Ongkir <code>*</code></label>
                                            <input type="disable" class="form-control" id="kode_transaksi"
                                                name="kode_transaksi" value="{{ $pembelian->ongkir ?? 0 }}">
                                        </div>
                                    </div>
                                    <div class="col-md-2 peminjam">
                                        <div class="mb-2">
                                            <label>Keterangan <code>*</code></label>
                                            <textarea id="keterangan" class="form-control" name="keterangan"
                                                style="height: 50px;" placeholder="Keterangan"></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {{-- //keterangan --}}
                            <div class="row">
                                <div class="col-md-12 table-responsive">
                                    <table class="table table-responsive table-bordered table-striped" id="tableList">
                                        <thead>
                                            <tr>
                                                <th class="text-center" style="width: 5%">No</th>
                                                <th class="text-center" style="width: 20%">Produk
                                                </th>
                                                <th class="text-center" style="width: 15%">kadaluarsa</th>
                                                <th class="text-center" style="width: 15%">Harga</th>
                                                <th class="text-center" style="width: 15%">Kuantiti</th>
                                                <th class="text-center" style="width: 15%">Harga Satuan</th>
                                                <th class="text-center" style="width: 15%">Harga Jual</th>
                                                <th class="text-center" style="width: 15%">Aksi</th>
                                            </tr>
                                        </thead>
                                        @foreach ($produk as $item)
                                            <tbody>
                                                <td class="text-center" style="width: 5%">
                                                    {{ $loop->iteration }}</td>
                                                <td class="text-center" style="width: 20%">
                                                    {{ $item->produk->nama }}</td>
                                                <td class="text-center" style="width: 15%">
                                                    {{ $item->kadaluarsa }}</td

<details>
<summary>英文:</summary>

hi i want to ask you something, i am having problem in my laravel project where i always find message &quot;message&quot;: &quot;Too few arguments to function App\\\\Http\\\\Controllers\\\\BursaPembelianController::edit_bursa_pembelian()....

please give me a solution to the problem I&#39;m facing regarding the error message, below I provide the source code view that I made.

view:

@extends('layouts.main')
@section('container')

&lt;body class=&quot;InvPinjam()&quot;&gt;
    &lt;div class=&quot;page-content&quot;&gt;
        &lt;div class=&quot;container-fluid&quot;&gt;
            &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-12&quot;&gt;
                    &lt;div class=&quot;page-title-box d-sm-flex align-items-center justify-content-between&quot;&gt;
                        &lt;h4 class=&quot;mb-sm-0 font-size-18&quot;&gt;{{ $label }}&lt;/h4&gt;
                        &lt;div class=&quot;page-title-right&quot;&gt;
                            &lt;ol class=&quot;breadcrumb m-0&quot;&gt;
                                &lt;li class=&quot;breadcrumb-item&quot;&gt;{{ ucwords($menu) }}&lt;/li&gt;
                                &lt;li class=&quot;breadcrumb-item&quot;&gt;{{ ucwords($submenu) }}&lt;/li&gt;
                            &lt;/ol&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;

            &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-xl-12&quot;&gt;
                    &lt;div class=&quot;card&quot;&gt;
                        &lt;div class=&quot;card-body&quot;&gt;
                            &lt;div class=&quot;row&quot;&gt;
                                &lt;div class=&quot;col-md-2 peminjam&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Kode Pembelian &lt;code&gt;*&lt;/code&gt;&lt;/label&gt;
                                        &lt;input type=&quot;disable&quot; class=&quot;form-control&quot; id=&quot;kode_transaksi&quot;
                                            name=&quot;kode_transaksi&quot; value=&quot;{{ $pembelian-&gt;kode_transaksi }}&quot; disabled&gt;
                                        &lt;input type=&quot;hidden&quot; name=&quot;purchase_id&quot; id=&quot;purchase_id&quot;
                                            value=&quot;{{ $pembelian-&gt;id }}&quot;&gt;
                                        &lt;input type=&quot;hidden&quot; name=&quot;url&quot; id=&quot;url&quot;
                                            value=&quot;{{ Crypt::encryptString($pembelian-&gt;kode_transaksi) }}&quot;&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 peminjam&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Tanggal &lt;code&gt;*&lt;/code&gt;&lt;/label&gt;
                                        &lt;input type=&quot;disable&quot; class=&quot;form-control&quot; name=&quot;tgl_kedatangan&quot;
                                            id=&quot;tgl_kedatangan&quot; value=&quot;{{ $pembelian-&gt;tgl_kedatangan }}&quot; readonly&gt;
                                        &lt;input type=&quot;disable&quot; class=&quot;form-control&quot; name=&quot;id_peminjam&quot; id=&quot;id_peminjam&quot;
                                            value=&quot;&quot; hidden&gt;
                                        {!! $errors-&gt;first(&#39;nama_peminjam&#39;, &#39;&lt;div class=&quot;invalid-validasi&quot;&gt;:message&lt;/div&gt;&#39;) !!}
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 wajib&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Supplier &lt;/label&gt;
                                        &lt;div class=&quot;input-group&quot;&gt;
                                            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;supplier&quot; id=&quot;supplier&quot;
                                                value=&quot;{{ $pembelian-&gt;id_supplier }}&quot;&gt;
                                            &lt;span class=&quot;input-group-text&quot;&gt;&lt;i class=&quot;mdi mdi-calendar&quot;&gt;&lt;/i&gt;&lt;/span&gt;

                                        &lt;/div&gt;
                                        {!! $errors-&gt;first(&#39;tgl_permintaan&#39;, &#39;&lt;div class=&quot;invalid-validasi&quot;&gt;:message&lt;/div&gt;&#39;) !!}
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 wajib&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Surat Jalan &lt;/label&gt;
                                        &lt;div class=&quot;input-group&quot;&gt;
                                            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;suratjalan&quot; id=&quot;suratjalan&quot;
                                                value=&quot;{{ $pembelian-&gt;nomor_do }}&quot;&gt;
                                            &lt;span class=&quot;input-group-text&quot;&gt;&lt;i class=&quot;mdi mdi-calendar&quot;&gt;&lt;/i&gt;&lt;/span&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 wajib&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Status Pembayaran &lt;/label&gt;
                                        &lt;div class=&quot;input-group&quot;&gt;
                                            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;pembayaran&quot; id=&quot;pembayaran&quot;
                                                value=&quot;{{ $pembelian-&gt;status_pembayaran }}&quot;&gt;
                                            &lt;span class=&quot;input-group-text&quot;&gt;&lt;i class=&quot;mdi mdi-calendar&quot;&gt;&lt;/i&gt;&lt;/span&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 wajib&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Potongan &lt;/label&gt;
                                        &lt;div class=&quot;input-group&quot;&gt;
                                            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;potongan&quot; id=&quot;potongan&quot;
                                                value=&quot;{{ $pembelian-&gt;potongan }}&quot;&gt;
                                            &lt;span class=&quot;input-group-text&quot;&gt;&lt;i class=&quot;mdi mdi-calendar&quot;&gt;&lt;/i&gt;&lt;/span&gt;
                                        &lt;/div&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;
                            {{-- keterengan --}}
                            &lt;div class=&quot;row&quot;&gt;
                                &lt;div class=&quot;col-md-2 peminjam&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Ongkir &lt;code&gt;*&lt;/code&gt;&lt;/label&gt;
                                        &lt;input type=&quot;disable&quot; class=&quot;form-control&quot; id=&quot;kode_transaksi&quot;
                                            name=&quot;kode_transaksi&quot; value=&quot;{{ $pembelian-&gt;ongkir ?? 0 }}&quot;&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                                &lt;div class=&quot;col-md-2 peminjam&quot;&gt;
                                    &lt;div class=&quot;mb-2&quot;&gt;
                                        &lt;label&gt;Keterangan &lt;code&gt;*&lt;/code&gt;&lt;/label&gt;
                                        &lt;textarea id=&quot;keterangan&quot; class=&quot;form-control&quot; name=&quot;keterangan&quot; style=&quot;height: 50px;&quot; placeholder=&quot;Keterangan&quot;&gt;&lt;/textarea&gt;
                                    &lt;/div&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;



                        &lt;/div&gt;
                        {{-- //keterangan --}}
                        &lt;div class=&quot;row&quot;&gt;
                            &lt;div class=&quot;col-md-12 table-responsive&quot;&gt;
                                &lt;table class=&quot;table table-responsive table-bordered table-striped&quot; id=&quot;tableList&quot;&gt;
                                    &lt;thead&gt;
                                        &lt;tr&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 5%&quot;&gt;No&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 20%&quot;&gt;Produk
                                            &lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;kadaluarsa&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;Harga&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;Kuantiti&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;Harga Satuan&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;Harga Jual&lt;/th&gt;
                                            &lt;th class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;Aksi&lt;/th&gt;
                                        &lt;/tr&gt;
                                    &lt;/thead&gt;
                                    @foreach ($produk as $item)
                                        &lt;tbody&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 5%&quot;&gt;
                                                {{ $loop-&gt;iteration }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 20%&quot;&gt;
                                                {{ $item-&gt;produk-&gt;nama }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;
                                                {{ $item-&gt;kadaluarsa }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;
                                                {{ $item-&gt;harga_total_produk }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;
                                                {{ $item-&gt;total_kuantiti }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;
                                                {{ $item-&gt;nilai_per_pcs }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot; style=&quot;width: 15%&quot;&gt;
                                                {{ $item-&gt;nilai_jual }}&lt;/td&gt;
                                            &lt;td class=&quot;text-center&quot;&gt;

                                                &lt;?php $id = Crypt::encryptString($item-&gt;id); ?&gt;
                                                &lt;form class=&quot;delete-form&quot;
                                                    action=&quot;{{ route(&#39;inv_pinjaman.destroy_invid&#39;, $id) }}&quot;
                                                    method=&quot;POST&quot;&gt;
                                                    @csrf
                                                    @method(&#39;DELETE&#39;)

                                                    &lt;div class=&quot;d-flex gap-3&quot;&gt;
                                                        &lt;a href class=&quot;text-danger delete_confirm&quot;&gt;&lt;i
                                                                class=&quot;mdi mdi-delete font-size-18&quot;&gt;&lt;/i&gt;&lt;/a&gt;
                                                    &lt;/div&gt;

                                                &lt;/form&gt;
                                            &lt;/td&gt;

                                        &lt;/tbody&gt;
                                    @endforeach

                                &lt;/table&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class=&quot;row mt-4&quot;&gt;
                            &lt;div class=&quot;col-sm-12&quot;&gt;
                                &lt;button class=&quot;btn btn-primary&quot; type=&quot;button&quot; id=&quot;tambahBaris&quot;&gt;Tambah
                                    Baris&lt;/button&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;


                        &lt;div class=&quot;row mt-4&quot;&gt;
                            &lt;div class=&quot;col-sm-12&quot;&gt;
                                &lt;a href=&quot;{{ route(&#39;bursa_pembelian.index&#39;) }}&quot;
                                    class=&quot;btn btn-secondary waves-effect&quot;&gt;Kembali&lt;/a&gt;
                                &lt;button class=&quot;btn btn-success&quot; type=&quot;button&quot; id=&quot;simpanDataBtn&quot;&gt;Simpan&lt;/button&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;br&gt;
    &lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;script src=&quot;{{ asset(&#39;assets/libs/jquery/jquery.min.js&#39;) }}&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;{{ asset(&#39;assets/alert.js&#39;) }}&quot;&gt;&lt;/script&gt;

&lt;script&gt;
    //form tambah baris
    document.getElementById(&quot;tambahBaris&quot;).addEventListener(&quot;click&quot;, function() {
        var table = document.getElementById(&quot;tableList&quot;);
        var row = table.insertRow();
        var rowCount = table.rows.length;

        var cell1 = row.insertCell(0);
        cell1.innerHTML = rowCount;

        var cell2 = row.insertCell(1);
        var pilihProduk = document.createElement(&quot;select&quot;);
        pilihProduk.className = &quot;form-control select select2 produk&quot;;
        pilihProduk.name = &quot;produk&quot;;
        pilihProduk.id = &quot;produk&quot;;
        pilihProduk.required = true;

        var defaultOption = document.createElement(&quot;option&quot;);
        defaultOption.value = &quot;&quot;;
        defaultOption.text = &quot;--PILIH PRODUK--&quot;;
        defaultOption.required = true;
        pilihProduk.appendChild(defaultOption);

        @foreach ($barang as $barangs)
            var option = document.createElement(&quot;option&quot;);
            option.value = &quot;{{ $barangs-&gt;id }}&quot;;
            option.dataset.id = &quot;{{ $barangs-&gt;nama }}&quot;;
            option.text = &quot;{{ $barangs-&gt;nama }}&quot;;
            pilihProduk.appendChild(option);
        @endforeach

        cell2.appendChild(pilihProduk);

        $(pilihProduk).select2({
            tags: true,
            allowClear: true
        });


        //tangal kadaluarsa
        var cell3 = row.insertCell(2);
        var kadaluarsa = document.createElement(&quot;input&quot;);
        kadaluarsa.type = &quot;text&quot;;
        kadaluarsa.className = &quot;form-control&quot;;
        kadaluarsa.name = &quot;kadaluarsa&quot;;
        kadaluarsa.id = &quot;kadaluarsa&quot;;
        kadaluarsa.placeholder = &quot;Kadaluarsa&quot;;
        kadaluarsa.required = true;

        cell3.appendChild(kadaluarsa);

        // Inisialisasi Datepicker
        $(kadaluarsa).datepicker({
            dateFormat: &#39;dd-mm-yy&#39;,
        });

        //Harga
        var cell4 = row.insertCell(3);
        cell4.innerHTML =
            &#39;&lt;input type=&quot;number&quot; class=&quot;form-control&quot; name=&quot;harga&quot; id=&quot;harga&quot; placeholder=&quot;Total Harga&quot; required&gt;&#39;;

        //kuantitas
        var cell5 = row.insertCell(4);
        cell5.innerHTML =
            &#39;&lt;input type=&quot;number&quot; class=&quot;form-control&quot; min=&quot;1&quot; name=&quot;kuantitas&quot; id=&quot;kuantitas&quot; placeholder=&quot;Jumlah&quot; oninput=&quot;updateHargaSatuan(this)&quot; required&gt;&#39;;

        //harga satuan
        var cell6 = row.insertCell(5);
        cell6.innerHTML =
            &#39;&lt;input type=&quot;number&quot; class=&quot;form-control&quot; name=&quot;harsat&quot; id=&quot;harsat&quot; placeholder=&quot;harsat&quot; readonly&gt;&#39;;


        //harga jual
        var cell7 = row.insertCell(6);
        cell7.innerHTML =
            &#39;&lt;input type=&quot;number&quot; class=&quot;form-control&quot; name=&quot;harjual[]&quot; id=&quot;harjual&quot; placeholder=&quot;Harga Jual&quot; required&gt;&#39;;

        //button hapus
        var cell8 = row.insertCell(7);
        cell8.innerHTML =
            &#39;&lt;button class=&quot;btn btn-danger&quot; type=&quot;button&quot; onclick=&quot;hapusBaris(this)&quot;&gt;Hapus&lt;/button&gt;&#39;;
    });

    function hapusBaris(button) {
        var row = button.parentNode.parentNode;
        row.parentNode.removeChild(row);
    }

    //fungsi untuk mengisi harga satuan
    function updateHargaSatuan(input) {
        var row = input.parentNode.parentNode;
        var hargaInput = row.querySelector(&#39;[name=&quot;harga&quot;]&#39;);
        var hargaSatuanInput = row.querySelector(&#39;[name=&quot;harsat&quot;]&#39;);

        var harga = parseFloat(hargaInput.value);
        var kuantitas = parseFloat(input.value);

        if (!isNaN(harga) &amp;&amp; !isNaN(kuantitas) &amp;&amp; kuantitas !== 0) {
            var hargaSatuan = harga / kuantitas;
            hargaSatuanInput.value = hargaSatuan.toFixed(2);
        }
    }


    $(&#39;#simpanDataBtn&#39;).click(function() {
        var dataedit = [];

        $(&#39;#tableList tbody tr&#39;).each(function() {
            var purchase_id = document.getElementById(&#39;purchase_id&#39;).value;
            var kode_transaksi = document.getElementById(&#39;kode_transaksi&#39;).value;
            var supplier = document.getElementById(&#39;supplier&#39;).value;
            var suratjalan = document.getElementById(&#39;suratjalan&#39;).value;
            var pembayaran = document.getElementById(&#39;pembayaran&#39;).value;
            var potongan = document.getElementById(&#39;potongan&#39;).value;
            var keterangan = document.getElementById(&#39;keterangan&#39;).value;

            var produk = $(this).find(&#39;[name=&quot;produk&quot;]&#39;).val();
            var kadaluarsa = $(this).find(&#39;[name=&quot;kadaluarsa&quot;]&#39;).val();
            var harga = $(this).find(&#39;[name=&quot;harga&quot;]&#39;).val();
            var kuantitas = $(this).find(&#39;[name=&quot;kuantitas&quot;]&#39;).val();
            var hargaSatuan = $(this).find(&#39;[name=&quot;harsat&quot;]&#39;).val();
            var hargaJual = $(this).find(&#39;[name=&quot;harjual&quot;]&#39;).val();


            var rowData = {
                purchase_id: purchase_id,
                kode_transaksi: kode_transaksi,
                supplier: supplier,
                suratjalan: suratjalan,
                pembayaran: pembayaran,
                potongan: potongan,
                keterangan: keterangan,
                produk: produk,
                kadaluarsa: kadaluarsa,
                harga: harga,
                kuantitas: kuantitas,
                hargaSatuan: hargaSatuan,
                hargaJual: hargaJual
            };

            dataedit.push(rowData);
        });

        $.ajax({
            type: &#39;POST&#39;,
            url: &#39;{{ route(&#39;bursa_pembelian.edit_jumlah_pembelian&#39;) }}&#39;,
            data: {
                &quot;_token&quot;: &quot;{{ csrf_token() }}&quot;,
                data: JSON.stringify({
                    data: dataedit
                })
            },
            success: (response) =&gt; {
                console.log(response)
                if (response.code === 200) {
                    Swal.fire(
                        &#39;Success&#39;,
                        `${response.message}`,
                        &#39;success&#39;
                    ).then(() =&gt; {
                        var APP_URL = {!! json_encode(url(&#39;/&#39;)) !!}
                        console.log(APP_URL)
                        url = document.getElementById(&quot;url&quot;).value;
                        window.location = APP_URL + &#39;/bursa/bursa_pembelian/&#39; +
                            url +
                            &#39;/edit&#39;
                    })
                } else {
                    Swal.fire(
                        &#39;Gagal&#39;,
                        `${response.message}`,
                        &#39;error&#39;,
                    )
                }
            },
            error: err =&gt; console.log(err)
        });
    });
&lt;/script&gt;

@endsection


web/routing:

Route::post('/edit_bursa_pembelian/{id}', [BursaPembelianController::class, 'edit_bursa_pembelian'])->name('bursa_pembelian.edit_jumlah_pembelian');


controller:

public function edit_bursa_pembelian(Request $request, $id)
{
    $updatepembelian = new BursaDetilPembelian();
    $updatepembelian-&gt;id_pembelian = $request-&gt;data[&#39;purchase_id&#39;];
    $updatepembelian-&gt;id_produk = $request-&gt;data[&#39;produk&#39;];
    $updatepembelian-&gt;harga_total_produk = $request-&gt;data[&#39;harga&#39;];
    $updatepembelian-&gt;total_kuantiti  = $request-&gt;data[&#39;kuantitas&#39;];
    $updatepembelian-&gt;nilai_per_pcs = $request-&gt;data[&#39;hargaSatuan&#39;];
    $updatepembelian-&gt;nilai_jual = $request-&gt;data[&#39;hargaJual&#39;];
    $updatepembelian-&gt;user_updated =  Auth::user()-&gt;id;
    $updatepembelian-&gt;save();
}

Detail Error
&quot;message&quot;: &quot;Too few arguments to function App\\Http\\Controllers\\BursaPembelianController::edit_bursa_pembelian(), 1 passed in D:\\Leo\\dw\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php on line 54 and exactly 2 expected&quot;,
&quot;exception&quot;: &quot;ArgumentCountError&quot;,
&quot;file&quot;: &quot;D:\\Leo\\dw\\app\\Http\\Controllers\\BursaPembelianController.php&quot;,
&quot;line&quot;: 311,

</details>


# 答案1
**得分**: 2

错误的原因是这个表达式:

```javascript
$.ajax({
  type: 'POST',
  url: '{{ route('bursa_pembelian.edit_jumlah_pembelian') }}',

当你使用带有一些参数的route函数时,你必须传递它们。

例如(来源自laravel文档):

Route::get('/user/{id}/profile', function (string $id) {
    // ...
})->name('profile');

$url = route('profile', ['id' => 1]);

因此,对于你的特定用例,你需要指定编辑资源的id($id是占位符):

{{ route('bursa_pembelian.edit_jumlah_pembelian', ['id' => $id]) }}
英文:

The reason for error is this expression:

$.ajax({
  type: &#39;POST&#39;,
  url: &#39;{{ route(&#39;bursa_pembelian.edit_jumlah_pembelian&#39;) }}&#39;,

When you are using route function with route that has some parameters, you have to pass them.

For example (source from the laravel docs):

Route::get(&#39;/user/{id}/profile&#39;, function (string $id) {
    // ...
})-&gt;name(&#39;profile&#39;);
 
$url = route(&#39;profile&#39;, [&#39;id&#39; =&gt; 1]);

So for your particular use case, you'd have to specify id of edited resource ($id is placeholder):

{{ route(&#39;bursa_pembelian.edit_jumlah_pembelian&#39;, [&#39;id&#39; =&gt; $id]) }}

huangapple
  • 本文由 发表于 2023年6月22日 19:10:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76531293.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定