Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement all solutions for the laravel blade-basic tasks #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/View/Components/AppLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AppLayout extends Component
*/
public function render()
{
return view('layouts.app');
$metaTitle = "Blade Test";
return view('layouts.app', compact('metaTitle') );
}
}
18 changes: 18 additions & 0 deletions app/View/Components/MainLayout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\View\Components;

use Illuminate\View\Component;

class MainLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.main');
}
}
2 changes: 1 addition & 1 deletion resources/views/alert.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">
{!! $text !!}
{{ $text }}
Your task is to change the code of alert.blade.php, to avoid that JavaScript alert.
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion resources/views/authenticated.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,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].
@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
1 change: 1 addition & 0 deletions resources/views/include.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<tr class="bg-red-100">
{{-- Task: include file resources/views/includes/row.blade.php --}}
{{-- passing the $user variable to it --}}
@include('includes.row', compact('user'))
</tr>
@endforeach
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-app-layout>
<x-main-layout>
<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 +10,4 @@
</div>
</div>
</div>
</x-app-layout>
</x-main-layout>
2 changes: 1 addition & 1 deletion resources/views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</head>
<body>
<div class="font-sans text-gray-900 antialiased">
@yield('content')
{{ $slot }}
</div>
</body>
</html>
6 changes: 3 additions & 3 deletions resources/views/rows.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<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 @if($loop->even) class="bg-red-100" @endif>
<td>{{ $loop->index }}</td>
<td>{{ $user->name }}</td>
{{-- Task: only the FIRST row should have email with "font-bold" --}}
<td class="font-bold">{{ $user->email }}</td>
<td @if($loop->first) class="font-bold" @endif>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@endforeach
Expand Down
5 changes: 4 additions & 1 deletion resources/views/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{{ __('Users') }}
</h2>
</x-slot>

<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 @@ -19,18 +18,22 @@
</thead>
{{-- Task: add the loop here to show users, or the row "No content" --}}
<tbody>
@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>
</div>
</div>
</div>

</x-app-layout>
Loading