Betmen35
use Illuminate\Support\Arr;
$time = $request->integer('time');
$until = $request->integer('until');
$clock = $request->integer('clock');
$untilClock = $request->integer('until_clock');
$clocks = Arr::crossJoin(range($clock, $untilClock - 1), [$untilClock]);
foreach(range($time, $until) as $date) {
foreach($clocks as $clock) {
$clock = implode('-', $clock);
$insertData[] = compact('date', 'clock');
}
}
[
[
"date" => 1,
"clock" => "8-10",
],
[
"date" => 1,
"clock" => "9-10",
],
[
"date" => 2,
"clock" => "8-10",
],
[
"date" => 2,
"clock" => "9-10",
],
]