Fix bug: Mark Completed should be shown to loggged in user only

This commit is contained in:
Thuan Bui
2025-03-06 22:57:54 +09:00
parent da2c4eeb6d
commit 0f9237c7a1
2 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -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'));
}
+9 -7
View File
@@ -12,13 +12,15 @@
<div><strong>Time Estimate:</strong> {{ $task->time_estimate }} hour</div>
<div><strong>Category:</strong> {{ $task->category->name }}</div>
<div><strong>Owner:</strong> {{ $task->user->name }}</div>
<div class="mt-4 mb-4">
<form action="/task/{{ $task->id }}/toggle" method="POST" class="d-inline" >
@csrf
@method('PATCH')
<x-form-button>{{ (! $task->completed) ? 'Mark Completed' : "Greate! You nailed it!" }}</x-form-button>
</form>
</div>
@auth
<div class="mt-4 mb-4">
<form action="/task/{{ $task->id }}/toggle" method="POST" class="d-inline" >
@csrf
@method('PATCH')
<x-form-button>{{ (! $task->completed) ? 'Mark Completed' : "Greate! You nailed it!" }}</x-form-button>
</form>
</div>
@endauth
</div>
<div class="mt-5">
<a href="/task/{{ $task->id }}/edit" class="text-sm text-blue-600 dark:text-blue-500 hover:underline">Edit</a>