Laravel - Insert Array of data into database

Laravel - Insert Array of data into database

Hello how can I achieve to insert data on an array? using eloquent? right now i have this on my

Hello how can I achieve to insert data on an array? using eloquent? right now i have this on my

Controller

public function insertSchedule(Request $request)
{
    $employAdd = [];

foreach($employAdd as $key){

    $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();    

}

}

View

See here my view? the dates here are arrays then when I insert this into the database the output or the data that is being inserted is the last data why is that?

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

                &lt;small&gt;Employee No. and Name: &lt;/small&gt;&lt;b&gt;&lt;i&gt; {{ $employee-&gt;employee_no }} : {{ $employee-&gt;last_name }}, {{ $employee-&gt;first_name }}&lt;/i&gt;&lt;/b&gt;

                &lt;input type="hidden" name="hidEmployeeno[]" value='&lt;?php echo $employee-&gt;employee_no ?&gt;'&gt;
                &lt;input type="hidden" name="hidEmployeeLast[]" value='&lt;?php echo $employee-&gt;last_name ?&gt;'&gt;
                &lt;input type="hidden" name="hidEmployeeFirst[]" value='&lt;?php echo $employee-&gt;first_name ?&gt;'&gt;
                &lt;hr&gt;

            &lt;/div&gt;

    &lt;/div&gt;


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

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

&lt;table class="table"&gt;
    &lt;thead&gt;
        &lt;tr&gt;
        &lt;th&gt;DATE TODAY&lt;/th&gt;
        &lt;th&gt;TIME IN&lt;/th&gt;
        &lt;th&gt;TIME OUT&lt;/th&gt;
        &lt;th&gt;ACTION&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        @foreach($dates as $date)
            &lt;tr&gt;
                &lt;td&gt;&lt;b&gt;{{ $date }}&lt;/b&gt;&lt;/td&gt;
                &lt;input type="hidden" name="dateToday[]" value="{{ $date }}"&gt;
                &lt;td&gt;&lt;input type="time" name="timeIn[]" class="form-control col-md-10"&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="time" name="timeOut[]" class="form-control col-md-10"&gt;&lt;/td&gt;
                &lt;td&gt; {{Form::button('&lt;i class="fa fa-clock"&gt;&amp;nbsp;&amp;nbsp;SET TIME&lt;/i&gt;',['type' =&gt; 'submit','class' =&gt; 'btn btn-warning btn-sm',  'style'=&gt;"display: inline-block;"])}}&lt;/td&gt;
            &lt;/tr&gt;
        @endforeach
    &lt;/tbody&gt;
&lt;/table&gt;

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


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Clear Cache in Laravel 6.8 App using Artisan Command Interface (CLI)

In Laravel 6 tutorial, we learn how to use PHP artisan command interface (CLI) to clear the cache from Laravel 6.8 application. How To Clear Cache in Laravel 6.8 Application using Artisan Command Line Interface (CLI)? How to clear route cache using php artisan command? How to easily clear cache in Laravel application? How to clear config cache in PHP Laravel via artisan command? How to clear Laravel view cache? How to Reoptimized class in Laravel via artisan CLI?

Get Weather Data with Laravel Weather

Get Weather Data with Laravel Weather. Laravel Weather is a good package which we can use to get weather data. It's a wrapper around Open Weather Map API (Current weather). A wrapper around Open Weather Map API (Current weather)

Laravel Sweet Alert | How to use the SweetAlert package in Laravel PHP

Sweet Alert is a laravel wrapper around #sweetalert javascript library for showing alert or notification message. This is a great package created by rashid, and this laravel package is very famous because it has tonnes of features you can choose from.