master
Rustem 2025-05-24 19:35:25 +05:00
parent ea036c8913
commit 2ba4146f5b
1 changed files with 4 additions and 5 deletions

View File

@ -238,13 +238,12 @@ class MobileApiController extends Controller
return false; return false;
} }
dd($color);
$started_at = Carbon::parse($started_at)->format('Y-m-d'); $started_at = Carbon::parse($started_at)->format('Y-m-d');
$ended_at = Carbon::parse($ended_at)->format('Y-m-d'); $ended_at = Carbon::parse($ended_at)->format('Y-m-d');
$cars = UniModel::model('pipi_auto') $cars = UniModel::model('pipi_auto')
->where('is_inactive', '=', false) ->where('is_inactive', '=', false)
->where('model_id', $modelId) ->where('model_id', $modelId)
->where('color_id', $color->first()->id) ->where('color_id', $color->id)
->get(); ->get();
$busyCars = UniModel::model('pipi_auto_calendar') $busyCars = UniModel::model('pipi_auto_calendar')
->whereBetween('date', [$started_at, $ended_at]) ->whereBetween('date', [$started_at, $ended_at])
@ -318,7 +317,7 @@ class MobileApiController extends Controller
$carsByColor = $cars->groupBy('color_id'); $carsByColor = $cars->groupBy('color_id');
foreach ($carsByColor as $carColor => $carsOfColor) { foreach ($carsByColor as $carColor => $carsOfColor) {
$carColor = UniModel::model('pipi_auto_colors')->find($carColor)->code; $carColor = UniModel::model('pipi_auto_colors')->find($carColor);
$colorPath = $path; $colorPath = $path;
if ($carsOfColor->first()->photo_id) { if ($carsOfColor->first()->photo_id) {
@ -326,11 +325,11 @@ class MobileApiController extends Controller
$colorPath = url('api/files/file/' . ltrim($photo->path, '/')); $colorPath = url('api/files/file/' . ltrim($photo->path, '/'));
} }
if (!$this->checkAvailableCar($started_at, $ended_at, $mark->id, $carsOfColor)) { if (!$this->checkAvailableCar($started_at, $ended_at, $mark->id, $carColor)) {
continue; continue;
} }
$key = $mark->name . '-' . $mark->year . '-' . $carColor; $key = $mark->name . '-' . $mark->year . '-' . $carColor->code;
$availableMarks[$key] = [ $availableMarks[$key] = [
'id' => $mark->id, 'id' => $mark->id,