From 137f308b97bf4939f674b9d00ea20eea45b0ec5b Mon Sep 17 00:00:00 2001 From: Ali-Sid <59683051+Ali-Sid@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:43:16 +0530 Subject: [PATCH 1/4] Update ViewsTest.php --- tests/Feature/ViewsTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Feature/ViewsTest.php b/tests/Feature/ViewsTest.php index 032b74ce..f188bb8f 100644 --- a/tests/Feature/ViewsTest.php +++ b/tests/Feature/ViewsTest.php @@ -4,6 +4,7 @@ use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class ViewsTest extends TestCase @@ -12,7 +13,11 @@ class ViewsTest extends TestCase public function test_users_list_get_with_values() { + $users = User::factory()->count(5)->create(); + $response = $this->get('users'); + $response->assertStatus(200); + $response->assertViewHas('usersCount', $users->count()); $response->assertOk(); } From f35ee1bdf6e5f9e4cb811339befbfea296c02fda Mon Sep 17 00:00:00 2001 From: Ali-Sid <59683051+Ali-Sid@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:52:48 +0530 Subject: [PATCH 2/4] Update HomeController.php --- app/Http/Controllers/HomeController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3ec9546d..9ea1a88a 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,7 +1,6 @@ $usersCount]); } // Task 2. Change the View code so alert would not show on the screen From 7276dcca1876d5b80de8f9183233973daf3810a0 Mon Sep 17 00:00:00 2001 From: Ali-Sid <59683051+Ali-Sid@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:59:38 +0530 Subject: [PATCH 3/4] Update HomeController.php --- app/Http/Controllers/HomeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 9ea1a88a..eb6688af 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -16,7 +16,7 @@ public function users() // Task 2. Change the View code so alert would not show on the screen public function alert() { - $text = ''; + $text = 'I am a security alert, your task is to remove me.'; return view('alert', compact('text')); } From b019860f165405e33dd3b934370ad4a28bf8b009 Mon Sep 17 00:00:00 2001 From: Ali-Sid <59683051+Ali-Sid@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:04:58 +0530 Subject: [PATCH 4/4] Update HomeController.php --- app/Http/Controllers/HomeController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index eb6688af..08853bc8 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -34,6 +34,10 @@ public function rows() { $users = User::all(); + if($users->isEmpty()) { + return view('rows', ['users' => 'No content']); + } + return view('rows', compact('users')); }