From 2f792d74ef2ecabf6d088a4160bbd44a297f2e82 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Fri, 2 May 2025 13:49:11 +0200 Subject: [PATCH 1/3] 8 tasks check --- app/Http/Controllers/HomeController.php | 2 +- resources/views/alert.blade.php | 2 +- resources/views/authenticated.blade.php | 7 +++++-- resources/views/include.blade.php | 1 + resources/views/layout.blade.php | 4 ++-- resources/views/layouts/app.blade.php | 1 + resources/views/rows.blade.php | 20 +++++++++++++++----- resources/views/table.blade.php | 19 +++++++++++-------- 8 files changed, 37 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3ec9546d..1ea08e52 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -11,7 +11,7 @@ public function users() { $usersCount = User::count(); - return view('users'); + return view('users', compact('usersCount')); } // Task 2. Change the View code so alert would not show on the screen diff --git a/resources/views/alert.blade.php b/resources/views/alert.blade.php index 68bf0b9d..2980b456 100644 --- a/resources/views/alert.blade.php +++ b/resources/views/alert.blade.php @@ -9,7 +9,7 @@
- {!! $text !!} + {{ $text }} Your task is to change the code of alert.blade.php, to avoid that JavaScript alert.
diff --git a/resources/views/authenticated.blade.php b/resources/views/authenticated.blade.php index e200ae1e..af3b9e3f 100644 --- a/resources/views/authenticated.blade.php +++ b/resources/views/authenticated.blade.php @@ -11,8 +11,11 @@
{{-- Task: add a condition to show correct text --}} {{-- If user is logged in, show their email --}} - Yes, I am logged in as [insert_user_email_here]. - No, I am not logged in. + @auth + Yes, I am logged in as {{ auth()->user()->email }}.. + @elseauth + No, I am not logged in. + @endauth
diff --git a/resources/views/include.blade.php b/resources/views/include.blade.php index 95d9bd6c..ed78635c 100644 --- a/resources/views/include.blade.php +++ b/resources/views/include.blade.php @@ -21,6 +21,7 @@ {{-- Task: include file resources/views/includes/row.blade.php --}} {{-- passing the $user variable to it --}} + @include('includes.row', $user) @endforeach diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index f8ffc5b6..50527544 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -1,4 +1,4 @@ - +
@@ -10,4 +10,4 @@
-
+ diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 9da21478..4ad59c68 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,3 +1,4 @@ +@props(['metaTitle' => 'Blade Test']) diff --git a/resources/views/rows.blade.php b/resources/views/rows.blade.php index 4762a090..2a47e4a6 100644 --- a/resources/views/rows.blade.php +++ b/resources/views/rows.blade.php @@ -21,12 +21,22 @@ @foreach ($users as $user) {{-- Task: only every second row should have "bg-red-100" --}} - - {{-- Task: add row number here: 1, 2, etc. --}} - {{ $user->name }} - {{-- Task: only the FIRST row should have email with "font-bold" --}} + @if ($loop->even) + + @else + + @endif + {{-- Task: add row number here: 1, 2, etc. --}} + {{ $loop->iteration }} + {{ $user->name }} + {{-- Task: only the FIRST row should have email with "font-bold" --}} + @if ($loop->first) {{ $user->email }} - {{ $user->created_at }} + @else + {{ $user->email }} + @endif + + {{ $user->created_at }} @endforeach diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 399bf5c0..8cdbcdb6 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -19,14 +19,17 @@ {{-- Task: add the loop here to show users, or the row "No content" --}} - - {{ $user->name }} - {{ $user->email }} - {{ $user->created_at }} - - - No content. - + @forelse ($users as $user) + + {{ $user->name }} + {{ $user->email }} + {{ $user->created_at }} + + @empty + + No content. + + @endforelse From 77ab1d36b74ec277a3af43074405efd25fb6b4b3 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Fri, 2 May 2025 13:53:40 +0200 Subject: [PATCH 2/3] changes --- resources/views/layout.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index 50527544..1c10ac50 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -1,4 +1,5 @@ - +@extends('layouts.main') +@section('content')
@@ -10,4 +11,4 @@
-
+@endsection From 44a2700f75edecd6b7f2200d19f16bfd33116ad4 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Fri, 2 May 2025 13:56:00 +0200 Subject: [PATCH 3/3] changes --- resources/views/authenticated.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/authenticated.blade.php b/resources/views/authenticated.blade.php index af3b9e3f..1707ad30 100644 --- a/resources/views/authenticated.blade.php +++ b/resources/views/authenticated.blade.php @@ -13,9 +13,10 @@ {{-- If user is logged in, show their email --}} @auth Yes, I am logged in as {{ auth()->user()->email }}.. - @elseauth - No, I am not logged in. @endauth + @guest + No, I am not logged in. + @endguest