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..06f84ba9 100644 --- a/resources/views/authenticated.blade.php +++ b/resources/views/authenticated.blade.php @@ -11,8 +11,12 @@
{{-- 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 }}. + @endauth + @guest + No, I am not logged in. + @endguest
diff --git a/resources/views/include.blade.php b/resources/views/include.blade.php index 95d9bd6c..f64f9940 100644 --- a/resources/views/include.blade.php +++ b/resources/views/include.blade.php @@ -11,18 +11,19 @@
- - - - + + + + - @foreach ($users as $user) - - {{-- Task: include file resources/views/includes/row.blade.php --}} - {{-- passing the $user variable to it --}} - - @endforeach + @foreach ($users as $user) + + {{-- Task: include file resources/views/includes/row.blade.php --}} + {{-- passing the $user variable to it --}} + {{ view('includes.row', ['user'=>$user])}} + + @endforeach
NameEmail
NameEmail
diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index f8ffc5b6..0926a216 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -1,13 +1,13 @@ - -
-
-
-
- {{-- Task: change the layout from layouts/app.blade.php --}} - {{-- to layouts/main.blade.php --}} - Please change layout. -
+@extends('layouts.main') +
+
+
+
+ Task: change the layout from layouts/app.blade.php + to layouts/main.blade.php + Please change layout.
- +
+ diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 9da21478..282cefd2 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -6,7 +6,7 @@ {{-- Task: edit one file to pass $metaTitle as "Blade Test" to all views --}} - {{ $metaTitle ?? 'Laravel' }} + {{ $metaTitle ?? 'Blade Test' }} diff --git a/resources/views/rows.blade.php b/resources/views/rows.blade.php index 4762a090..6ad3847f 100644 --- a/resources/views/rows.blade.php +++ b/resources/views/rows.blade.php @@ -11,24 +11,32 @@
- - - - - - + + + + + + - @foreach ($users as $user) - {{-- Task: only every second row should have "bg-red-100" --}} + @foreach ($users as $index=>$user) + {{-- Task: only every second row should have "bg-red-100" --}} + @if($index % 2 == 0) - + @else + + @endif + {{-- Task: only the FIRST row should have email with "font-bold" --}} - + @if($index == 0) + + @else + + @endif - @endforeach + @endforeach
Row NumberNameEmailRegistered at
Row NumberNameEmailRegistered at
{{-- Task: add row number here: 1, 2, etc. --}}
{{-- Task: add row number here: 1, 2, etc. --}} {{$index}} {{ $user->name }}{{ $user->email }}{{ $user->email }}{{ $user->email }}{{ $user->created_at }}
diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 399bf5c0..eef380c6 100644 --- a/resources/views/table.blade.php +++ b/resources/views/table.blade.php @@ -11,22 +11,26 @@
- - - - - + + + + + {{-- Task: add the loop here to show users, or the row "No content" --}} + + @forelse($users as $user) + @empty + @endforelse
NameEmailRegistered at
NameEmailRegistered at
{{ $user->name }} {{ $user->email }} {{ $user->created_at }}
No content.