From 1b0d4b6c420271ef64151ef69d99dcf7c9262d51 Mon Sep 17 00:00:00 2001 From: Maxence Bonamy Date: Sun, 21 Jan 2024 15:06:49 +0100 Subject: [PATCH] Add task selection logic to sidebar button --- resources/views/components/sidebar/button.blade.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/resources/views/components/sidebar/button.blade.php b/resources/views/components/sidebar/button.blade.php index c675b65..5d5f817 100644 --- a/resources/views/components/sidebar/button.blade.php +++ b/resources/views/components/sidebar/button.blade.php @@ -6,8 +6,18 @@ @php +use App\Models\Task; + $selected = request()->path() == $href; +// Check if task is in the url +if (str_contains(request()->path(), 'task') && request()->route()->hasParameter('id')) { + $task = Task::find(request()->route()->parameter('id')); + if ($href == "project/".$task->project_id) { + $selected = true; + } +} + @endphp