master
parent
fab3679f53
commit
83d62045bd
|
|
@ -226,7 +226,7 @@ class MobileApiController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function checkAvailableCar($started_at = null, $ended_at = null, $modelId = null): bool {
|
||||
public function checkAvailableCar($started_at = null, $ended_at = null, $modelId = null, $color = null): bool {
|
||||
if (!$started_at || !$ended_at || !$modelId) {
|
||||
$request = request();
|
||||
$started_at = $started_at ?? $request->input('started_at');
|
||||
|
|
@ -243,6 +243,7 @@ class MobileApiController extends Controller
|
|||
$cars = UniModel::model('pipi_auto')
|
||||
->where('is_inactive', '=', false)
|
||||
->where('model_id', $modelId)
|
||||
->where('color_id', $color->first()->id)
|
||||
->get();
|
||||
$busyCars = UniModel::model('pipi_auto_calendar')
|
||||
->whereBetween('date', [$started_at, $ended_at])
|
||||
|
|
@ -284,10 +285,6 @@ class MobileApiController extends Controller
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!$this->checkAvailableCar($started_at, $ended_at, $mark->id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cars = UniModel::model('pipi_auto')->where('model_id', $mark->id)->get();
|
||||
|
||||
|
||||
|
|
@ -328,6 +325,10 @@ class MobileApiController extends Controller
|
|||
$colorPath = url('api/files/file/' . ltrim($photo->path, '/'));
|
||||
}
|
||||
|
||||
if (!$this->checkAvailableCar($started_at, $ended_at, $mark->id, $carsOfColor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = $mark->name . '-' . $mark->year . '-' . $carColor;
|
||||
|
||||
$availableMarks[$key] = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue