Cara mencegah mengulang nilai opsi yang sama dari pilihan dalam loop php
public function getProductById(Request $request)
{
$response = '';
$product = Product::find($request->productId);
$groups = Group::all();
foreach ($groups as $group) {
if ($group->id != $product->group_id) {
//exclude this record
$response .= "<option value='" . $group->id . "'>";
$response .= $group->group_name;
$response .= "</option>";
}
}
}
SAMER SAEID