mardi 8 février 2022

How to optimize the load of many data options into a select box using laravel

I'm selecting product name and code from the database and populating into dropdown and I have more than 40000 products in DB when clicking the dropdown it's very slow to open and sometimes it's not opening. Please help how to solve this issue.

Controler

public function create()
{
  $arr["product"] = product::where('prod_flag', 1)->pluck('prod_product_code', 'product_name');
        

        return view('backend.product_category.create')->with($arr);
}

View Blade File

 <div class="form-group">
        <label for="exampleInputEmail1">Product</label>
        <select class="form-control select2" id="catpro_prod_code" name="catpro_prod_code">
             <option>Select Product</option>
                @foreach($product as $prodName => $prodCode)
                     <option value=""></option>
                @endforeach
        </select>
   </div>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire