lundi 28 janvier 2019

Laravel - Inserting data only the last list or data

I want to insert the data specifically look at my page

enter image description here

so when I Set Time the data will be inserted. but what i have right now is the data that is inserted is the very last data on this table which is January-31-2019 how can I fix it so when I insert data, the data will insert any of the data that is list on the table.

Controller

 public function insertSchedule(Request $request)
{

    $employeeTimeSet = new Schedule;
    $employeeTimeSet->employee_no = $request->input('hidEmployeeno'); 
    $employeeTimeSet->last_name = $request->input('hidEmployeeLast'); 
    $employeeTimeSet->first_name = $request->input('hidEmployeeFirst'); 
    $employeeTimeSet->date_today = $request->input('dateToday'); 
    $employeeTimeSet->time_in = $request->input('timeIn'); 
    $employeeTimeSet->time_out = $request->input('timeOut'); 
    $employeeTimeSet->save();

    $notification = array(
        'message' => 'Click PLAN TIME! Employee Time Set!',
        'alert-type' => 'success'
    );
    return redirect()->back()->with($notification, 'Employee Time Set');
}

View

here is my form.

   {!! Form::open(['action' => 'Admin\EmployeeFilemController@insertSchedule', 'method' => 'POST']) !!}
        <div class="row">
                <div class="form-group col-md-12">

                    <small>Employee No. and Name: </small><b><i>  : , </i></b>

                    <input type="hidden" name="hidEmployeeno" value='<?php echo $employee->employee_no ?>'>
                    <input type="hidden" name="hidEmployeeLast" value='<?php echo $employee->last_name ?>'>
                    <input type="hidden" name="hidEmployeeFirst" value='<?php echo $employee->first_name ?>'>
                    <hr>

                </div>

        </div>


        @php
        $today = today(); 
        $dates = []; 

        for($i=1; $i < $today->daysInMonth + 1; ++$i) {
            $dates[] = \Carbon\Carbon::createFromDate($today->year, $today->month, $i)->format('F-d-Y');
        }
    @endphp

    <table class="table">
        <thead>
            <tr>
            <th>DATE TODAY</th>
            <th>TIME IN</th>
            <th>TIME OUT</th>
            <th>ACTION</th>
            </tr>
        </thead>
        <tbody>
            @foreach($dates as $date)
                <tr>
                    <td><b></b></td>
                    <input type="hidden" name="dateToday" value="">
                    <td><input type="time" name="timeIn" class="form-control col-md-10"></td>
                    <td><input type="time" name="timeOut" class="form-control col-md-10"></td>
                    <td> </td>
                </tr>
            @endforeach
        </tbody>
    </table>

          {!! Form::close() !!}



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WsBmdG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire