Sorry, I am new to this forum, I do not know how to past the html code to show correctly!
laravel retrive old() wherein query values
I have 2 multiple value select lists that I pass users between them using jquery.
select multiple="multiple" id="ListAllUsers" class="form-control" @foreach ($users as $user) option class="content" value="{{ $user->id }}" {{ $user->name }} /option @endforeach /select
select name="user_id[]" required multiple="multiple" id="SelectedUsers" class="form-control" @if (!empty(old('user_id')) && $create_form) @foreach ($old_value_users as $old_user) option class="content" value="{{ $old_user->id }}" {{ $old_user->name }} /option @endforeach @endif /select
Now, my issue is that when I go and pass the old('user_id') value in the whereIn query, I only get the first result of the array instead of all of the results that are passed in.
$old_users_id = [old('user_id')]; $old_value_users = User::whereIn('id', $old_users_id)->get();
If I replace $old_users_id = [old('user_id')] with $old_users_id = [1,2,3], it works like a charm. I have dd(old('user_id')) and it is indeed an array, so I do not understand what is the hick-up!
Please or to participate in this conversation.