diff --git a/app/Http/Controllers/GoalController.php b/app/Http/Controllers/GoalController.php index 15a7a6b..061fdde 100644 --- a/app/Http/Controllers/GoalController.php +++ b/app/Http/Controllers/GoalController.php @@ -6,8 +6,6 @@ use App\Http\Requests\UpdateGoalRequest; use App\Models\Goal; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Auth; class GoalController extends Controller @@ -15,17 +13,10 @@ class GoalController extends Controller /** * Display a listing of the resource. */ - public function index(Request $request): View + public function index(): View { - if ($request->date) { - $date = Carbon::createFromFormat('Y-m-d', $request->date); - } - else { - $date = Carbon::now(); - } return view('goals.index') - ->with('date', $date) - ->with('goals', Auth::user()->getGoalsByTime($date)); + ->with('goals', Goal::whereUserId(Auth::user()->id)->get()); } /** @@ -51,10 +42,7 @@ class GoalController extends Controller */ public function show(Goal $goal): View { - return view('goals.show') - ->with('goal', $goal) - ->with('nameOptions', Goal::getNameOptions()) - ->with('frequencyOptions', Goal::$frequencyOptions); + return view('goals.show')->with('goal', $goal); } /** @@ -62,10 +50,7 @@ class GoalController extends Controller */ public function edit(Goal $goal): View { - return view('goals.edit') - ->with('goal', $goal) - ->with('nameOptions', Goal::getNameOptions()) - ->with('frequencyOptions', Goal::$frequencyOptions); + return view('goals.edit')->with('goal', $goal); } /** diff --git a/resources/views/goals/index.blade.php b/resources/views/goals/index.blade.php index b450361..599d9b8 100644 --- a/resources/views/goals/index.blade.php +++ b/resources/views/goals/index.blade.php @@ -1,63 +1,51 @@ - My Goals - {{ $date->format('D, j M Y') }} + My Goals
-

-
My Goals
-
- -
-
- - -
- -
-

+

My Goals

Add Goal
-
- @forelse($goals['present'] as $goal) -
- - - - - - - - - - - -
{{ $goal->summary }}
-
- @empty -
No goals set.
- @endforelse -
+ + + + + + + + + + + + + @foreach($goals as $goal) + + + + + + + + + @endforeach + +
NameFromToDays of WeekGoals 
{{ $goal->name }}{{ $goal->from }}{{ $goal->to }}{{ $goal->days }} + Calories: {{ $goal->calories }}
+ Carbohydrates: {{ $goal->carbohydrates }}
+ Cholesterol: {{ $goal->cholesterol }}
+ Fat: {{ $goal->fat }}
+ Protein: {{ $goal->Protein }}
+ Sodium: {{ $goal->sodium }}
+
+
+ + Edit + + + Delete + +
+