Ajout de la vue index pour afficher les tâches avec leurs niveaux et états

This commit is contained in:
Luka COUTANT
2025-06-10 14:38:19 +02:00
parent 427c4406c8
commit a565da5dca
5 changed files with 59 additions and 2 deletions

View File

@@ -13,7 +13,8 @@ class LevelController extends Controller
*/ */
public function index() public function index()
{ {
// $level = Level::all();
return view('index', compact('level'));
} }
/** /**

View File

@@ -13,7 +13,8 @@ class TaskController extends Controller
*/ */
public function index() public function index()
{ {
// $tasks = Task::with('level')->get();
return view('index', compact('tasks'));
} }
/** /**

View File

@@ -15,4 +15,9 @@ class Task extends Model
'details', 'details',
'state', 'state',
]; ];
function level()
{
return $this->belongsTo(Level::class);
}
} }

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Tasks !</title>
<style>
.termine { color: green; font-weight: bold; }
.encours { color: red; font-weight: bold; }
</style>
{{-- <link rel="stylesheet" href="https://cdn.datatables.net/2.3.2/css/dataTables.dataTables.min.css"> --}}
</head>
<body>
<div id="contenu">
<table id="tasks">
<thead>
<tr>
<th>Priority</th>
<th>Titre</th>
<th>Detail</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@foreach ($tasks as $task)
<tr>
<td>{{ $task->level->name }}</td>
<td>{{ $task->title }}</td>
<td>{{ $task->details }} </td>
<td>
@if($task->state)
<span class="termine">Terminé</span>
@else
<span class="encours">En cours</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/2.3.2/js/dataTables.min.js"></script>
<script>
new DataTable("#tasks")
</script> --}}
</body>
</html>

View File

@@ -1,7 +1,10 @@
<?php <?php
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TaskController;
Route::get('/', function () { Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::resource('tasks', TaskController::class);