Skip to content

Commit

Permalink
added extra data
Browse files Browse the repository at this point in the history
  • Loading branch information
j.m.lucas committed Jan 16, 2024
1 parent ad370ff commit c1144cd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public function createEvents(Request $request, string $id): ApiEloquentSucessRes

$validator = Validator::make($request->all(), [
'events' => 'required|array',
'events.*' => 'required|array|size:3',
'events.*' => 'required|array|size:4',
'events.*.0' => 'required|string|in:' . implode(',', TripEventEnum::values()),
'events.*.1' => 'required|numeric',
'events.*.2' => '',
'events.*.3' => ''
]);

if ($validator->fails()) {
Expand All @@ -78,12 +79,13 @@ public function createEvents(Request $request, string $id): ApiEloquentSucessRes
$events = $request->get('events');

foreach ($events as $eventData) {
list($eventType, $timestamp, $eventData) = $eventData;
list($eventType, $timestamp, $eventData, $eventData2) = $eventData;

$trip->events()->create([
'type' => $eventType,
'timestamp' => $timestamp,
'data' => $eventData,
'data2' => $eventData2
]);
}

Expand Down

0 comments on commit c1144cd

Please sign in to comment.