0
My system controls vehicle travel. When the customer inserts a particular trip to a line, this line has two vehicles associated with it. Then he takes the period, for example from 04/02/2019
to 08/02/2019
, takes these two vehicles and inserts the trips in the travel table, through the while
. Only I need to alternate the vehicles, each day it will insert a different vehicle. I wanted to try to do this without having to consult the travel chart at each one insert
within the while
.
public function store_teste(Request $request)
{
$inicio = implode("-", array_reverse(explode("/", $request->input('inicio'))));
$fim = implode("-", array_reverse(explode("/", $request->input('fim'))));
$veiculo1 = $request->input('veiculo1');
$veiculo2 = $request->input('veiculo2');
while (strtotime($inicio) <= strtotime($dtfim2)) {
//ROTINA DO INSERT
//Na primeira passagem pelo while vai inserir o veículo1
//Na segunda passagem pelo while vai inserir o veículo2
//Na terceira pasagem pelo while vai inserir o veículo1
//Na quarta pasagem pelo while vai inserir o veículo2
$inicio = date ("Y-m-d", strtotime("+1 day", strtotime($inicio)));
}
}
There is no fixed day of the month or week, the first registration inserted will the vehicle 1, the second goes the 2. And then it alternates depending on the amount of days.
Can someone help me with this logic?