From 75557fc633a1d9f61db13b7565bb9b56180aadd9 Mon Sep 17 00:00:00 2001 From: asadbekuzz Date: Mon, 23 Sep 2024 16:42:32 +0500 Subject: [PATCH] blade test completed --- app/Http/Controllers/HomeController.php | 4 +- app/View/Components/Forms/Input.php | 26 +++ composer.json | 1 + composer.lock | 156 +++++++++++++++++- database/blade | Bin 0 -> 49152 bytes resources/views/authenticated.blade.php | 8 +- .../views/components/forms/input.blade.php | 3 + .../views/components/forms/textarea.blade.php | 3 + resources/views/dashboard.blade.php | 2 +- resources/views/include.blade.php | 1 + resources/views/layout.blade.php | 6 +- resources/views/rows.blade.php | 9 +- resources/views/table.blade.php | 19 ++- resources/views/test.blade.php | 1 + storage/debugbar/.gitignore | 2 + 15 files changed, 221 insertions(+), 20 deletions(-) create mode 100644 app/View/Components/Forms/Input.php create mode 100644 database/blade create mode 100644 resources/views/components/forms/input.blade.php create mode 100644 resources/views/components/forms/textarea.blade.php create mode 100644 resources/views/test.blade.php create mode 100644 storage/debugbar/.gitignore 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 @@ +c zy7s^!RWG~nNAMSM;?4oia6ue-w&TQZ+|r?47JV%xvEQ$}_jx}eKeu~N9y*~gjy%6( zhsJ&7rlP9K7lxrI@>Egg?2`%S4nt!fK@E&Me9 z_k1w-_3ST|&dh5W%z*#`2q1s}0&iQO|M8rr?`^34ZydKJPP)PmJlAepcC#shzzV$= z!X12AJ=b~J6U9m9w{{zw`win@XZy)P!`R;Ws`0I17N<>09TaC8o_kqB(^xU%8kn`d zJ*(+IZm4Is|FfRDd0M@j{#$b}#fCx9N+H za6`lOPty*N$g2{qtqD|9(6gj%=qbQ~cl^23D^p$4D~5 zGr^U@VVy~k&6o6lCNdhoQMs~fS2RsuURKZbxN9?MGN&{7PRzta1!Zlo)pPMT7xh=u zb6wF49nVd0vwbNicu)3KWS$M~+NW*LmSg8)gg9x6ZgEkA`e%Dchvre$&9sw;FagMEMEj73@p)+oi>=v`6%teEY8Pf zGY%$dK0#z07cLi@#c55yBdcI16EUB#o4>q~@3jlDqf(1{B3ayuVu}WJ%`R(tU03^B zEFP9pkp2jA@OSv)$D-d$7xbjyr ze_6^oU5H$X8h=;jto1)qHGOGGJ-Zc`*>Rrvb~KHG(b-h4By$w;zgB}`_MyRWGD?g? zJ8V85{W7F$cP+X%FIPWRs=ro$uKMzX0|5jOKmY**5I_I{1Q0*~0R&QkjdEFeRaslD zZ&>v;tG;fnMn~OBc6F@cJzOi^3Ak4(D|V7~^)pKr5NBOYvt~90lk{s-WyOiouUqxi z_}k(PY5H_?B;7uXzhgx$D+k#;`R|DLc9PPg`~RuxA4>I4`Nn|&0tg_000IagfB*sr zAbPmBJesQdeztN*B`7u_$2zL{`mg?AD|FG009ILKmY**5I_I{1Q0-A z(gd{9VkO!KNT2^tTKi}Z0tg_000IagfB*srAb

@@ -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