i am using Jquery Tag-it. When i pass tag-it values to controller and check it by var_dump(); all the values post perfectly but the problem i that when it pass to DB it will store only last value .. please help me out
<input type="text" value="" data-role="tagsinput" id="tags" name="wish-tags" class="form-control">
Controller
$wishlist = Wishlist::firstOrNew(['user_id' => Auth::user()->id]);
if (!empty($wishlist)) {
$locations = $request->input('wish-tags');
//var_dump($locations); exit();
foreach (explode(",", $locations) as $location) {
$wishlist->update([
'user_id' => Auth::user()->id,
'locations' => $location,
]);
}
}
via Jamal Ahmad