Open jesnagifto opened 8 months ago
help me please?
Maybe this will help
... ->get(['brands_id', DB::raw('brand_name as text')]); ..
to
->get([DB::raw('brand_category.brands_id as id'), DB::raw('brand_name as text')]);
For API...
public function brands(Request $request)
{
$brand = $request->get('q');
$brandNames = Brand_category::where('category_id', $brand)
->join('brands', 'brand_category.brands_id', '=', 'brands.id')
->get([DB::raw('brand_category.brands_id as id'), DB::raw('brand_name as text')]);
log::info($brandNames);
return $brandNames;
}
For Form...
$form->select('catg_id', __('Category Name'))
->options(Category::all()->pluck('catg_name', 'id'))
->ajax('/admin/api/brands');
OR
$form->select('catg_id', 'Select Category')->options(function ($id) {
$category= Category::find($id);
if ($category) {
return [$category->id => $category->brand_name ];
}
})
->ajax('/admin/api/brands');
Description:
public function brands(Request $request) { $brand = $request->get('q'); $brandNames = Brand_category::where('category_id', $brand) ->join('brands', 'brand_category.brands_id', '=', 'brands.id') ->get(['brands_id', DB::raw('brand_name as text')]); log::info($brandNames);
}
Steps To Reproduce:
$form->select('catg_id', __('Category Name')) ->options(Category::all()->pluck('catg_name', 'id')) ->setWidth(4, 2) ->load('brand_id', '/admin/api/brands'); $form->select('brand_id', __('Brand Name')) ->setWidth(4, 2);
this code wise load the values we can not selecthem.