diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 3ec9546d..251ed94a 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -3,15 +3,16 @@
namespace App\Http\Controllers;
use App\Models\User;
+use Illuminate\Support\Facades\View;
class HomeController extends Controller
{
// Task 1. Change the Controller code to pass the variable to the View
public function users()
{
- $usersCount = User::count();
+ $usersCount = User::all();
- return view('users');
+ return view('usersCount', compact('usersCount'));
}
// Task 2. Change the View code so alert would not show on the screen
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 38c135bd..9d82817c 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -25,5 +25,8 @@ public function register()
public function boot()
{
//
+ View::composer('layouts.app', function ($view) {
+ $view->with('metaTitle', 'Laravel 8');
+ });
}
}
diff --git a/resources/views/alert.blade.php b/resources/views/alert.blade.php
index 68bf0b9d..244a2208 100644
--- a/resources/views/alert.blade.php
+++ b/resources/views/alert.blade.php
@@ -9,8 +9,8 @@
- {!! $text !!}
- Your task is to change the code of alert.blade.php, to avoid that JavaScript alert.
+ {{-- {!! $text !!} --}}
+ {{ $text }}
diff --git a/resources/views/authenticated.blade.php b/resources/views/authenticated.blade.php
index e200ae1e..6d9e1e3c 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 }}.
+ @else
+ No, I am not logged in.
+ @endauth
diff --git a/resources/views/include.blade.php b/resources/views/include.blade.php
index 95d9bd6c..54f178fe 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('include.row', ['user' => $user])
@endforeach
diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php
index f8ffc5b6..ceb38905 100644
--- a/resources/views/layout.blade.php
+++ b/resources/views/layout.blade.php
@@ -1,4 +1,6 @@
-
+@extends('layouts.main')
+
+@section('content')
-
+@endsection
diff --git a/resources/views/rows.blade.php b/resources/views/rows.blade.php
index 4762a090..5d8e0c2e 100644
--- a/resources/views/rows.blade.php
+++ b/resources/views/rows.blade.php
@@ -21,11 +21,14 @@
@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: add row number here: 1, 2, etc. --}}
+ {{$index + 1 }}
+ |
+ {{$user->name}} |
+ {{-- {{$user->email}} | --}}
{{-- Task: only the FIRST row should have email with "font-bold" --}}
- {{ $user->email }} |
+ {{ $user->email }} |
{{ $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