diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php
index 14225d1..e4e4f89 100644
--- a/app/Http/Controllers/TaskController.php
+++ b/app/Http/Controllers/TaskController.php
@@ -10,10 +10,10 @@ use Illuminate\Support\Facades\Auth;
class TaskController extends Controller
{
public function index() {
- $task = Task::latest('updated_at')->Paginate(20);
- return view('task.index', [
- 'tasks' => $task
- ]);
+ $totalTasks = Task::count(); // Count all tasks
+ $completedTasks = Task::where('completed', true)->count(); // Coun
+ $tasks = Task::latest('updated_at')->Paginate(20);
+ return view('task.index', compact('tasks','totalTasks','completedTasks'));
}
public function show(Task $task) {
diff --git a/app/Models/Task.php b/app/Models/Task.php
index e3fb24b..ed32e0f 100644
--- a/app/Models/Task.php
+++ b/app/Models/Task.php
@@ -18,7 +18,7 @@ class Task extends Model
if (is_null($task->completed)) {
$task->completed = false; // Ensure completed is false when creating a new task
}
- $task->user_id = Auth::id(); // Set user_id automatically
+ $task->user_id = Auth::id(); // Set user_id automatically
});
}
diff --git a/resources/views/task/index.blade.php b/resources/views/task/index.blade.php
index 207af44..bc84e79 100644
--- a/resources/views/task/index.blade.php
+++ b/resources/views/task/index.blade.php
@@ -9,18 +9,25 @@
-
+
+ Progress: {{ $completedTasks}} / {{ $totalTasks }} completed.
+
@foreach ($tasks as $task)
-
-
Where to go: {{ $task->location }}
-
Time Estimate: {{ $task->time_estimate }}
+
+
+
+
Where to go: {{ $task->location }}
+
Time Estimate: {{ $task->time_estimate }}
+
+
+
{{ ($task->completed) ? "Completed" : "" }}
+
+
@endforeach
{{$tasks -> links()}}
-
-
-$completedCount = Task::where('completed', true)->count();
\ No newline at end of file
+
\ No newline at end of file
diff --git a/resources/views/task/show.blade.php b/resources/views/task/show.blade.php
index 159d273..67b3ab4 100644
--- a/resources/views/task/show.blade.php
+++ b/resources/views/task/show.blade.php
@@ -4,12 +4,21 @@
-
{{ $task->description }}
+
+
What need to do
+
{{ $task->description }}
+
Where to go: {{ $task->location }}
Time Estimate: {{ $task->time_estimate }} hour
Category: {{ $task->category->name }}
Owner: {{ $task->user->name }}
-
+
+
+
Edit
diff --git a/routes/web.php b/routes/web.php
index b7af915..b0420bf 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -12,8 +12,6 @@ use Illuminate\Validation\Rules\Password;
use Illuminate\Validation\ValidationException;
-
-
Route::get('/', [TaskController::class, 'index']);
Route::get('/task', [TaskController::class, 'index'])->name('task.index');
Route::get('/task/create', [TaskController::class, 'create']);
@@ -22,6 +20,8 @@ Route::post('/task/create', [TaskController::class, 'store'])->name('task.create
Route::delete('/task/{task}', [TaskController::class, 'destroy']);
Route::get('/task/{task}/edit', [TaskController::class, 'edit']);
Route::patch('/task/{task}', [TaskController::class, 'update']);
+Route::patch('/task/{task}/toggle', [TaskController::class, 'toggleComplete']);
+
Route::get('/register', [UserRegisterController::class, 'register']);
Route::post('/register', [UserRegisterController::class, 'store']);