<?php

namespace App\Http\Controllers;


use App\Classes\Service\BulkBookings;
use App\Imports\BookingImport;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use Carbon\Carbon;
use Illuminate\Support\Collection;

class BulkBookingController
{
    public function index(Request $request){
        $bookings = Excel::toArray(new BookingImport(), $request->file('xsl'));
        foreach (array_slice($bookings[0],1) as $booking){
            (new BulkBookings(Carbon::createFromTimestamp(($booking[0] - 25569) * 86400), $booking[1], $booking[2], $booking[3], $booking[4], $booking[5]))->execute();
        }
        return redirect()->route('booking.bulk.form');
    }
}