Complete all stats

This commit is contained in:
Thuan Bui
2025-04-04 11:57:49 +09:00
parent fcea780b69
commit c7bf3ea95d
6 changed files with 72 additions and 4 deletions
+5 -2
View File
@@ -12,7 +12,7 @@ class ProjectController extends Controller
{
// TASK: Currently this statement fails. Fix the underlying issue.
Project::create([
'name' => $request->name
'name' => $request->name,
]);
return redirect('/')->with('success', 'Project created');
@@ -26,6 +26,9 @@ class ProjectController extends Controller
// where name = $request->old_name
// Insert Eloquent statement below
Project::where('name', $request->old_name)
->update(['name' => $request->new_name]);
return redirect('/')->with('success', 'Projects updated');
}
@@ -35,7 +38,7 @@ class ProjectController extends Controller
Project::destroy($projectId);
// TASK: change this Eloquent statement to include the soft-deletes records
$projects = Project::all();
$projects = Project::withTrashed()->get();
return view('projects.index', compact('projects'));
}