i need to create a batch(team) for finishing a job , their are many team members in a single batch


This Content is from Stack Overflow. Question asked by Abhishek Negi

I have a 3 table in my database Job_requisition , Batch , Batch members.
first i created a new model for selecting multiple team members for a batch.
Now we need to store team members id in Batch members table.
Batch table contains batch_id which is foreign key of batch members table.


enter code h    <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="batchMembersModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="batchMembersModalLabel">Batch Members Details</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            <div class="modal-body">
                {{-- @dd($member) --}}
                <form id="batchDetailsForm" action="{{ route('requisition.storeBatchDetails', ["id" => $member->id]) }}" method="post">
                    <input type="hidden" id="batchId" name="batchId" value="{{$member->id}}">
                    <label for="teamMembersDropdown">Select Team Members</label>
                    <select class="form-control"  name="teamMembers[]" multiple="multiple">
                        @foreach ($employees as $employee)
                            <option value="{{ $employee->id }}">{{ $employee->name }}</option>
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary">Save changes</button>

after submiting a form batch table id should auto update currently its not working.
my controller

    public function storeBatchDetails(Request $request ,$id)
    // dd($request->all());
    $requisitions = $this->service->showCompletedRequisition();
    $batchMembers = $request->get('teamMembers');
    $id = $request->get('batchId');
    foreach($batchMembers as $batchMember){
            'batch_id' => $id,
            'employee_id' => $batchMember,

i want when a select a team member those members id should go in batch_members table and that batch id will go in batch table .


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?