Skip to content

Commit

Permalink
blade test completed
Browse files Browse the repository at this point in the history
  • Loading branch information
asadbekkuz committed Sep 23, 2024
1 parent 4b534fd commit 75557fc
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<script>alert("I am a security alert, your task is to remove me.");</script>';
$text = '&lt;script&gt;alert("I am a security alert, your task is to remove me.");&lt;script&gt;';

return view('alert', compact('text'));
}
Expand Down
26 changes: 26 additions & 0 deletions app/View/Components/Forms/Input.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Input extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.forms.input');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"laravel/tinker": "^2.8"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.13",
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
Expand Down
156 changes: 154 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added database/blade
Binary file not shown.
8 changes: 6 additions & 2 deletions resources/views/authenticated.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@php use Illuminate\Support\Facades\Auth; @endphp
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Expand All @@ -11,8 +12,11 @@
<div class="p-6 bg-white border-b border-gray-200">
{{-- 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
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions resources/views/components/forms/input.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
<!-- It is not the man who has too little, but the man who craves more, that is poor. - Seneca -->
</div>
3 changes: 3 additions & 0 deletions resources/views/components/forms/textarea.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
<!-- Be present above all else. - Naval Ravikant -->
</div>
2 changes: 1 addition & 1 deletion resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
You're logged in!
Blade Test
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/views/include.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<tbody>
@foreach ($users as $user)
<tr class="bg-red-100">
@include('includes.row',['user' => $user])
{{-- Task: include file resources/views/includes/row.blade.php --}}
{{-- passing the $user variable to it --}}
</tr>
Expand Down
6 changes: 4 additions & 2 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<x-app-layout>
@extends('layouts.main')

@section('content')
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
Expand All @@ -10,4 +12,4 @@
</div>
</div>
</div>
</x-app-layout>
@endsection
9 changes: 6 additions & 3 deletions resources/views/rows.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
<tbody>
@foreach ($users as $user)
{{-- Task: only every second row should have "bg-red-100" --}}
<tr class="bg-red-100">
<td>{{-- Task: add row number here: 1, 2, etc. --}}</td>
<tr @class(['bg-red-100' => $loop->iteration % 2 === 0 ])>
<td>
{{-- Task: add row number here: 1, 2, etc. --}}
{{ $loop->iteration }}
</td>
<td>{{ $user->name }}</td>
{{-- Task: only the FIRST row should have email with "font-bold" --}}
<td class="font-bold">{{ $user->email }}</td>
<td @class(['font-bold' => $loop->iteration === 1])>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@endforeach
Expand Down
19 changes: 11 additions & 8 deletions resources/views/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
</thead>
{{-- Task: add the loop here to show users, or the row "No content" --}}
<tbody>
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
<tr>
<td colspan="3">No content.</td>
</tr>
@forelse($users as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@empty
<tr>
<td colspan="3">No content.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/views/test.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{-- This is comment in blade template, it will not render in HTML --}}
2 changes: 2 additions & 0 deletions storage/debugbar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 75557fc

Please sign in to comment.