Skip to content

Commit

Permalink
Store locations
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmant committed Mar 10, 2024
1 parent a0b7d89 commit eae2631
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/EntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function store(Request $request)
'time' => 'required|date_format:H:i:s|time_required',
]);

$entry = new Entry($request->only('distance', 'time'));
$entry = new Entry($request->only('distance', 'time', 'locations'));
$entry->user_id = auth()->id();
$entry->date = Carbon::parse($request->get('date'));
$entry->speed = $entry->distance / ($entry->seconds() / 3600);
Expand Down
15 changes: 8 additions & 7 deletions app/Models/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Entry extends Model
* @var array
*/
protected $fillable = [
'date', 'distance', 'time',
'date', 'distance', 'time', 'locations',
];

/**
Expand All @@ -26,12 +26,13 @@ class Entry extends Model
* @var array
*/
protected $casts = [
'user_id' => 'int',
'date' => 'date',
'distance' => 'float',
'time' => 'string',
'speed' => 'float',
'pace' => 'float',
'user_id' => 'int',
'date' => 'date',
'distance' => 'float',
'time' => 'string',
'speed' => 'float',
'pace' => 'float',
'locations' => 'json',
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function up()
$table->time('time');
$table->decimal('speed');
$table->decimal('pace');
$table->json('locations');
$table->timestamps();
});
}
Expand Down

0 comments on commit eae2631

Please sign in to comment.