What i am trying to do is get data from table (it is ajax request), sort and send to view. Want show in select box options. I have to change id with value to make JS sort by value.
Quick example
ModelVehicle::where('make_id', $request->make_id)->orderBy('name')->pluck('id', 'name');
and JS
$("#model_id").empty();
$("#model_id").append(new Option(data.please_select, 0));
$.each(data.models, function(index, item) {
$("#model_id").append(new Option(index, item));
});
In this case this is exactly what i need but now i need use map cause i am using language file and i have code below
Category::find($request->category_id)->orderBy('public_name')->pluck('id', 'public_name')->map(function ($key, $item) {
return __('general.' . $item . '');
})
but the result is
I tried modify map func but with no result. Is any way to do this on backend side ? or should i use JS to sort and modify my array ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire