diff --git a/app/Http/Controllers/GoalController.php b/app/Http/Controllers/GoalController.php index a714a4e..407f361 100644 --- a/app/Http/Controllers/GoalController.php +++ b/app/Http/Controllers/GoalController.php @@ -62,10 +62,13 @@ class GoalController extends Controller if (isset($attributes['days'])) { $attributes['days'] = array_sum($attributes['days']); } + else if (!empty($goal->days)) { + $attributes['days'] = null; + } $goal->fill($attributes)->user()->associate(Auth::user()); $goal->save(); session()->flash('message', "Goal updated!"); - return redirect()->route('goals.show', $goal); + return redirect()->route('goals.index'); } /** diff --git a/resources/views/goals/edit.blade.php b/resources/views/goals/edit.blade.php index b9a1f16..52f5832 100644 --- a/resources/views/goals/edit.blade.php +++ b/resources/views/goals/edit.blade.php @@ -22,12 +22,12 @@
-
+
Days of the week -
+
@foreach(\App\Models\Goal::days() as $day) - - + + {{ \Illuminate\Support\Str::ucfirst($day['label']) }} @endforeach