jeudi 25 juillet 2019

Dropdown menu from any table in database - Laravel

i have trouble here. Hope you can help me. :)

So, the case is, i have a form, which is have some text field. let me explain this field, So_number from table sales_order so_date from table sales_order customer_name from table customers

and then i've got linked all of model and controller and views

My controller is linked of my 3 models. and i try to call with this, as same as like variable as i made,

I call the details with this <td><a href="/so//details"></a></td>

this is my web.php of details ``` Route::get('/so/{so_number}/details', 'So_Controller@details'); ````

this is my So_Controller @ details,

    {
        $data_so = \App\Sales_Order::all();
        $data_so_detail = \App\Sales_Order_Details::all();
        $data_customer = \App\Customer_Model::all();
        return view('salesorder.details', ['data_so_detail' => $data_so_detail, 'data_so' => $data_so, 'data_customer' => $data_customer]);
    } ```

This is my views of my details.index.php
``` <div class="modal-body">
                                        <div class="col-md-6">
                                        <div class="form-group form-animate-text" style="margin-top:40px !important;">
                                        <input type="text" name="so_number" value="" class="form-text" required>
                                                <span class="bar"></span>
                                                <label for="so_number">Sales Order Number</label>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group form-animate-text" style="margin-top:40px !important;">
                                        <input type="text" name="so_date" value="" class="form-text" required>
                                              <span class="bar"></span>
                                              <label for="so_date">Sales Order Date.</label>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group form-animate-text" style="margin-top:40px !important;">
                                        <label for="customer_name">Customer Name</label>
                                        <select name="customer_name" id="customer_name">
                                            @foreach ($data_customer as $customerName)
                                                <option value=""></option>
                                            @endforeach
                                        </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group form-animate-text" style="margin-top:40px !important;">
                                            <label for="customer_id"></label>
                                            <select name="customer_id" id="customer_id">
                                                @foreach ($data_customer as $customerId)
                                            <option value=""></option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div> ```

And the error is
``` ErrorException (E_ERROR)
Property [so_number] does not exist on this collection instance. (View: /Applications/XAMPP/xamppfiles/htdocs/belajar_laravel/resources/views/salesorder/details.blade.php)
Previous exceptions

    Property [so_number] does not exist on this collection instance. (0)

i expect the output is, list of items in dropdown. please help me everyone.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32UlC6q
via IFTTT

Aucun commentaire:

Enregistrer un commentaire