diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 3ec9546d..0821226f 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -11,13 +11,13 @@ 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 public function alert() { - $text = ''; + $text = '<script>alert("I am a security alert, your task is to remove me.");<script>'; return view('alert', compact('text')); } diff --git a/app/View/Components/Forms/Input.php b/app/View/Components/Forms/Input.php new file mode 100644 index 00000000..74f580ce --- /dev/null +++ b/app/View/Components/Forms/Input.php @@ -0,0 +1,26 @@ +

@@ -11,8 +12,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. + @if(Auth::check()) + Yes, I am logged in as {{ auth()->user()->email }}. + @else + No, I am not logged in. + @endif
diff --git a/resources/views/components/forms/input.blade.php b/resources/views/components/forms/input.blade.php new file mode 100644 index 00000000..bfb6e604 --- /dev/null +++ b/resources/views/components/forms/input.blade.php @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/resources/views/components/forms/textarea.blade.php b/resources/views/components/forms/textarea.blade.php new file mode 100644 index 00000000..1c97e0e7 --- /dev/null +++ b/resources/views/components/forms/textarea.blade.php @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 025a79a4..a7d45887 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -9,7 +9,7 @@
- You're logged in! + Blade Test
diff --git a/resources/views/include.blade.php b/resources/views/include.blade.php index 95d9bd6c..95e564da 100644 --- a/resources/views/include.blade.php +++ b/resources/views/include.blade.php @@ -19,6 +19,7 @@ @foreach ($users as $user) + @include('includes.row',['user' => $user]) {{-- Task: include file resources/views/includes/row.blade.php --}} {{-- passing the $user variable to it --}} 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')
@@ -10,4 +12,4 @@
-
+@endsection diff --git a/resources/views/rows.blade.php b/resources/views/rows.blade.php index 4762a090..4a048a72 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. --}} + $loop->iteration % 2 === 0 ])> + + {{-- Task: add row number here: 1, 2, etc. --}} + {{ $loop->iteration }} + {{ $user->name }} {{-- Task: only the FIRST row should have email with "font-bold" --}} - {{ $user->email }} + $loop->iteration === 1])>{{ $user->email }} {{ $user->created_at }} @endforeach diff --git a/resources/views/table.blade.php b/resources/views/table.blade.php index 399bf5c0..72b9b73c 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 diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php new file mode 100644 index 00000000..d82f2076 --- /dev/null +++ b/resources/views/test.blade.php @@ -0,0 +1 @@ +{{-- This is comment in blade template, it will not render in HTML --}} diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore