From 0f9237c7a131457ed8eedefde7b096777aa7e65f Mon Sep 17 00:00:00 2001 From: Thuan Bui <9248622+10h30@users.noreply.github.com> Date: Thu, 6 Mar 2025 22:57:54 +0900 Subject: [PATCH] Fix bug: Mark Completed should be shown to loggged in user only --- app/Http/Controllers/TaskController.php | 2 +- resources/views/task/show.blade.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index e4e4f89..486e7f6 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -12,7 +12,7 @@ class TaskController extends Controller public function index() { $totalTasks = Task::count(); // Count all tasks $completedTasks = Task::where('completed', true)->count(); // Coun - $tasks = Task::latest('updated_at')->Paginate(20); + $tasks = Task::latest()->Paginate(20); return view('task.index', compact('tasks','totalTasks','completedTasks')); } diff --git a/resources/views/task/show.blade.php b/resources/views/task/show.blade.php index 67b3ab4..d2a16a5 100644 --- a/resources/views/task/show.blade.php +++ b/resources/views/task/show.blade.php @@ -12,13 +12,15 @@
Time Estimate: {{ $task->time_estimate }} hour
Category: {{ $task->category->name }}
Owner: {{ $task->user->name }}
-
-
- @csrf - @method('PATCH') - {{ (! $task->completed) ? 'Mark Completed' : "Greate! You nailed it!" }} -
-
+ @auth +
+
+ @csrf + @method('PATCH') + {{ (! $task->completed) ? 'Mark Completed' : "Greate! You nailed it!" }} +
+
+ @endauth
Edit