From eae2631011f49ecc00b240ea16227b2e9af2dc2e Mon Sep 17 00:00:00 2001 From: Vedmant Date: Sun, 10 Mar 2024 18:01:18 +0700 Subject: [PATCH] Store locations --- app/Http/Controllers/EntryController.php | 2 +- app/Models/Entry.php | 15 ++++++++------- .../2016_12_13_204920_create_entries_table.php | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/EntryController.php b/app/Http/Controllers/EntryController.php index a652836..3cea70b 100644 --- a/app/Http/Controllers/EntryController.php +++ b/app/Http/Controllers/EntryController.php @@ -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); diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 4154545..8e763af 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -17,7 +17,7 @@ class Entry extends Model * @var array */ protected $fillable = [ - 'date', 'distance', 'time', + 'date', 'distance', 'time', 'locations', ]; /** @@ -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', ]; diff --git a/database/migrations/2016_12_13_204920_create_entries_table.php b/database/migrations/2016_12_13_204920_create_entries_table.php index a765846..981f767 100644 --- a/database/migrations/2016_12_13_204920_create_entries_table.php +++ b/database/migrations/2016_12_13_204920_create_entries_table.php @@ -22,6 +22,7 @@ public function up() $table->time('time'); $table->decimal('speed'); $table->decimal('pace'); + $table->json('locations'); $table->timestamps(); }); }